<p>There are three <a href="http://buildwithcraft.com/docs/sections-and-entries#section-types" rel="noreferrer">types of sections</a> in Craft: singles, structures, and channels. You can use <code>entry.section.type</code> to test if the current page is displaying one of these section types.</p>

<pre><code>{% if entry.section.type == "channel" %}

    &lt;p&gt;This is a channel&lt;/p&gt;

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

    &lt;p&gt;This is a single&lt;/p&gt;

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

    &lt;p&gt;This is a structure&lt;/p&gt;

 {% endif %}
</code></pre>

CC BY-SA 3.0
2015-07-01T16:42:09.317Z
2015-07-01T16:42:09.317Z
Dylan T
<p>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?</p>

<p>i.e</p>

<pre><code>{% if I'm currently viewing an entry %}
    do this
{% else %}
    do this
{% endif %}
</code></pre>

<variable>
Variable to check if viewing an entry?
# Variable to check if viewing an entry?

(Asked by: username_0 on 2015-07-01)

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?
i.e
{% if I'm currently viewing an entry %}
    do this
{% else %}
    do this
{% endif %}

**Tags:** variable

---

## 1 answers

### Answer by username_1 on 2015-07-01. Score: 5 | Accepted answer

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" %}

    This is a channel

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

    This is a single

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

    This is a structure

 {% endif %}


---

