How would I write a variable to detect if the current page/Url I'm viewing is for an entry, rather than a section home page or a single?


{% if I'm currently viewing an entry %}
    do this
{% else %}
    do this
{% endif %}

1 Answer 1


There are three types of sections in Craft: singles, structures, and channels. You can use entry.section.type to test if the current page is displaying one of these section types.

{% if entry.section.type == "channel" %}

    <p>This is a channel</p>

{% elseif entry.section.type == "single" %}

    <p>This is a single</p>

 {% elseif entry.section.type == "structure" %}

    <p>This is a structure</p>

 {% endif %}

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.