Detecting if page is a 'category' or 'entry' Is there another way of detecting if a page is an 'entry' or a 'category' than the following? Maybe some global variable that I do not know of?

{% if entry is defined %}
  &lt;!-- Code here --&gt;
{% endif %}
{% if category is defined %}
  &lt;!-- Code here --&gt;
{% endif %}


I have a html code block that is included in both entry pages and category pages hence the need for this.

Thanks in advance!
It'd be nice to see an example of your HTML block. From your comments it sounds like you may be using the same HTML block for Entry and Category pages but need to know which variable to use in the code.

Assuming you know that your code is running on the Entry or Category pages, and that the fields across both your Entries and Categories for this part of the page are the same, you can place your common HTML in an include and pass both the entry and category variable to that include with the same variable name.  In the example below, we're handing off the entry and category variables and using the variable name object in the include template:

_entry.html

{% include '_partials/shared-template' with { object : entry } %}


_category.html

{% include '_partials/shared-template' with { object : category } %}


_partials/shared-template

&lt;div&gt;
    {{ object.fieldName }}

    {% for item in object.someOtherFieldName %}
      {{ item }}
    {% endfor %}
&lt;/div&gt;


If some of the field names are different, you may need to use some conditional logic or reconsider what variables are being passed to the included template.  You could pass dissimilar variables under the same variable names to a common template in the following way:

index.html

{% if entry is defined %}
    {% include '_partials/shared-template' with { 
        title : entry.title,
        someOtherVariable: entry.fancyFieldOne
    } %}
{% endif %}

{% if category is defined %}
    {% include '_partials/shared-template' with { 
        title : category.title,
        someOtherVariable: category.fancyFieldTwo
    } %}
{% endif %}


_partials/shared-template

&lt;div&gt;
    {{ title }}

    {% for item in someOtherVariable %}
      {{ item }}
    {% endfor %}
&lt;/div&gt;