Magento custom html/css layout - how?

Magento custom html/css layout - how?

August 20, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento custom html/css layout - how?

Implementing Custom HTML/CSS Layouts in Magento

Hello everyone! I’m glad you reached out about integrating your existing HTML/CSS layout into a new Magento installation. Let’s dive right in and walk through the process step-by-step.

Understanding the Magento Theme Structure

First, let me provide some context on how Magento handles themes and layouts. When you install Magento, it comes with a default theme called “luma” which is based on Bootstrap. The theme files are located under app/design/frontend folder.

Each theme consists of two main parts:

  1. Theme Configuration: Found in app/design/frontend/Your_Vendor/Your_Theme/etc/theme.xml. This file defines the theme’s name, settings, and inheritance.

  2. Template Files: Located in app/design/frontend/Your_Vendor/Your_Theme/Magento_Module/... folders. These are the actual HTML, CSS, JavaScript, and image files that make up your storefront.

Getting Started with Your Custom Layout

To use your custom layout, you’ll need to create a new theme folder under app/design/frontend. I recommend naming it something like “custom-layout”.

mkdir app/design/frontend/Your_Vendor/Custom_Layout

Next, copy the necessary files from your existing HTML website into this new folder. You should have a structure that looks similar to:

<your_vendor_custom_layout>
  ├── index.php
  ├── .htaccess
  └── app
      └── design
          └── frontend
              └── Your_Vendor
                  └── Custom_Layout
                      ├── index.php
                      ├── .htaccess
                      └── theme.xml

Configuring the Theme File

The theme.xml file is crucial for defining your theme’s settings. Here’s a basic example:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <theme>
        <code>Your_Vendor_Custom_Layout</code>
        <label>Custom Layout Theme</label>
        <parent>Magento/blank</parent>
        <media>
            <preview_image path="Magento/blank/images/theme_preview.jpg"/>
        </media>
    </theme>
</config>

Replace Your_Vendor_Custom_Layout with the appropriate name for your theme. The parent attribute should be set to “Magento/blank” if you want a clean slate.

Integrating Your Custom Files

Now, let’s move on to integrating your custom HTML and CSS files. I recommend creating a folder structure similar to Magento’s default layout under app/design/frontend/Your_Vendor/Custom_Layout/Magento_Theme/.

For example:

<your_vendor_custom_layout>
  ├── index.php
  ├── .htaccess
  └── app
      └── design
          └── frontend
              └── Your_Vendor
                  └── Custom_Layout
                      ├── index.php
                      ├── .htaccess
                      └── theme.xml
                      └── Magento_Theme
                          ├── layout
                          │   ├── default.xml
                          │   └── ...
                          ├── template
                          │   ├── html
                          │   │   ├── head.phtml
                          │   │   ├── header.phtml
                          │   │   └── ...
                          │   └── ...
                          └── web
                              ├── css
                              │   └── style.css
                              └── ...

You can copy your existing CSS files into Magento_Theme/web/css and HTML templates (if any) into Magento_Theme/template/html. Remember to keep the file names as close to Magento’s default naming conventions as possible for maximum compatibility.

Overriding Default Layout

To make sure your custom layout is applied instead of Magento’s Luma theme, you need to override the default layout XML files. Create a new folder called app/design/frontend/Your_Vendor/Custom_Layout/Magento_Theme/layout/default.xml and define your layout rules:

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/layout.xsd">
    <referenceContainer name="before.body.start">
        <block class="MyVendor\CustomLayout\Block\YourBlock" template="Magento_Theme::your-template.phtml"/>
    </referenceContainer>
</layout>

Replace MyVendor with your actual vendor name, and update the block class and template to match your custom code.

Conclusion

And that’s it! With these steps, you should have a solid foundation for integrating your existing HTML/CSS layout into Magento. Remember that theme development in Magento can be complex, so don’t hesitate to refer to the official Magento Developer Guide or check out some great resources like the Laravel Company Blog.

Happy coding!

Philip, I’m glad you’ve found this guide helpful. Let me know if there’s anything else I can assist with in your Magento journey.

Best, [Your Name]

Extensions Themes Configuration JavaScript

Our network