How to create a New Custom Email Header Template in magento2 and load it into the emails? How to create multiple headers.

3 Answers 3

  1. Marketing -> Email Templates -> Add New Template
  2. Load Default Template "Magento_Email:Header"
  3. Edit "Template Content" and save template as "custom_header"
  4. Content -> Design - Configuration
  5. Open "Global" configuration
  6. Transactional Emails -> Header Template: select "custom_header"

Go to

Marketing -> Email Templates -> Add New Template

and load any default templates from drop-down there

Edit "Template Content" and save template as "custom_email_template"

then open the "Global Configuration" inside:

Content -> Design - Configuration


Transactional Emails -> Header Template: select "custom_email_template"

You are good to go. Please accept kudos as a solution.


Working Code


<template id="design_custom_email_header_template" label="Custom Header" file="header-custom.html" type="html" module="[VENDOR_MODULE]" area="frontend"/>


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="Magento\Config\Model\Config\Source\Email\Template\Header" type="Magento\Config\Model\Config\Source\Email\Template">
            <argument name="data" xsi:type="array">
                <item name="path" xsi:type="string">design/custom_email/header_template</item>


<!--@subject {{trans "Header"}} @-->
<!--@vars {
"var logo_url":"Email Logo Image URL",
"var logo_alt":"Email Logo Alt Text",
"var logo_height":"Email Logo Image Height",
"var logo_width":"Email Logo Image Width",
"var template_styles|raw":"Template CSS"
} @-->

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Welcome To {{var logo_alt}}</title>
<body style="margin: 0 auto; /*height: 11.7in;*/ width: 8.3in;">
                <td><img src="{{var logo_url}}" alt=""
                        style=" width: 7rem; height: 2rem; "></td>

Use the below code to load the custom header in the template

{{template config_path="design/custom_email/header_template"}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.