How Can I Contextualize The Template?

91ae607fd65685445a22f34936444eff

Written By Jose Souza (Administrator)

Updated at December 19th, 2017

Is possible to hide or show different parts of your template according to the current page being accessed using liquid tags.

This is a fairly simple process that essentially just require some test conditions, and those test out which page the user is currently on,  there are some specific tags like:

  • on_show_question_page: Variable that returns a true value if the current page is a question;
  • on_index_page: Variable that returns a true value if the current page is the index page;
  • on_contact_us_page: Variable that returns a true value if the current page is the contact-us page;

and using a similar tactic you can also test the code below

category != null

the latter being actually a logical text that could be read as “ category is not null”.


An example of usage for the tags:

{% if on_show_question_page %}
  <!--content for question page>
{% elsif on_index_page %}
  <!--content for index page-->
{% elsif on_contact_us_page %}
  <!--content for contact page→
{% elsif category != null %}
  <!--content for category page-->
{% endif %}

Was this article helpful?