Want to create your own html templates, but don't know where to start? Don't worry — we'll tell you how to use Mailchimp Template Language to create unique emails.
Template Language consists of Mailchimp tags. It is enough to just place them in an email layout once, and then you can edit your html template in the visual editor. This means you won't have to dig into your code in order to change text, images, or single blocks in your email. The edited layout will load up as an ordinary template in the Templates tab.
In this article, we will tell you how to use the Template Language. The text combines elements of the original guide and our own additions to some confusing points.
Imortant! Always remember to backup the source code, otherwise you put it at risk. Also, always test your email templates before sending them to the subscribers.
How to Edit Text, Links, and Images Using Mailchimp Template Language
The first and most important feature is that you can edit text, links, and images in your emails. It can be done by placing an "mc:edit" element into the code.
mc:edit is used in the opening <dev> or any other content container. Syntax is mc:edit=»$unique name». The name inside the quotation marks should be unique for every block.
You should highlight the edited spaces with the empty <div> tags in order not to lose the text styles. Mailchimp won't give you such advice, but our experience shows that you'd better do it.
Here is another precaution for the styles to stay still: first add the new text, then delete the old text.
To edit a link, you should:
- highlight the part of the text that contains a link (not the whole text!);
- write the new word;
- delete the text you don't need;
- change the link if necessary.
If you do it in any other way, Mailchimp will wrap the word with the link and the text style will be changed to the default setting.
How to Edit Images Using Mailchimp Template Language
If you want to edit images only, use mc:edit=»$unique name» inside the <img> tag. This will bring out the image replacement menu in the campaign editor.
If you add a tag, a new separate window for image editing will show up. You can use it to replace or edit an image, add links and alt-text.
Notes:
- You can't place one editable element inside of another one;
- You can't place editable images inside editable elements;
- Do not upload an image with a different scale. It can make the whole email layout display incorrectly;
- If you design your emails with images for retina, the images will probably be displayed with full scale in the editor. However, in the emails sent, they will have the preset look.
How to Hide an Element in an Email Template in Mailchimp
Use the mc:hideable tag to hide a certain element of the letter. It is suitable for any element of the html code.
Just write mc:hideable in any element you need to hide. You don't need any unique name for this tag. If needed, just wrap the hideable element with the <div>...</div> tags.
Notes:
- Do not use this tag in places where you have used the mc:repeatable tag;
- You can hide elements in the block editor only in the campaign editor. The hidden element will be highlighted with the dim gray colour. You can see the result in the preview mode or in a test email;
- Add this element to all of the editable blocks, so you can remove any of them at any moment.
How to Duplicate an Element in Your Email Using Mailchimp Template Language
Use the mc:repeatable tag if you want to duplicate an element or a block in the visual editor. This tag is suitable for the block or inline elements of the html code.
Notes:
- Repeated elements can be inserted into each other. However, you should use this feature carefully if you don't want to bring out any errors while reduplicating the blocks;
- The duplicated blocks can be swapped.
How to Create an Element with an Opportunity to Choose Block Types
Use the mc:variant tag if you want to create a space that allows you to choose block types. It is pasted together with mc:repeatable=»$block name» (this tag is used for reduplication).
Syntax: mc:repeatable=»content» mc:variant=»variant_1″.
Notes:
- The blocks with mc:variant tag should be placed next to each other;
- The name for such blocks should be given in mc:repeatable and be the same everywhere. In our examples, the name is mc:repeatable=«content»;
- The blocks should not be inserted into each other;
- You can replace the blocks only in the campaign editor, not in an email template.
Limitations of Mailchimp Template Language
- The Template Language is not a no-code solution: you still have to dig into the code and write some tags if you want to edit your email layout in the visual editor.
- You can't change the source structure of an email layout, i.e. you can duplicate the elements of your email, but not change their position;
- At the editing stage, the text styles might get lost. To avoid this, add the new text first and only then delete the old text.
- Some elements can be edited in campaigns only, not in templates;
- The way emails look at the editing stage may differ from the way they will look like in the end. That's why it is important to check your emails in the preview mode or to send test emails.