Template Tags

Template tags are a bit of an oddments drawer you can use to do a variety of things within your code. They can do things like prevent comments from being output, display raw Liquid code, and sometimes control output of template elements. Let’s take a look at the comment tag, as you’ll be reading and (and hopefully entering) comments in your code!

{% comment %} 
I wrote the code this way for a good reason!
{% endcomment %}

The output is… nothing! That means your comments are visible to someone reading the Liquid code, but your customers won’t see a thing in the email. 

Practice problem: template tags

See if you can identify the correct way to use the comment tag. Add the comment “Insert new product information here” to your code.

Select the right Liquid code from the options below:

That’s not right; try again!

The correct answer is C!

Let’s run the code.

{% comment %} 
Insert new product information here
{% endcomment %}

Why don’t the other options work?

A) Missing the closing section of the tag.

B) Uses double curly braces instead of paired curly brace and percentage signs to enclose the tag.

D) Tag is missing.

Up Next: Intermediate Tags – Operators and Order of Operations