<p>Figured it out. </p>

<pre><code>    {% set categories = craft.categories.group('fellowsCat') %}

 &lt;ul&gt;
  {% nav category in craft.categories
    .group('fellowsCat')
    %}
    &lt;li&gt;
      &lt;a href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;
      {% ifchildren %}
        &lt;ul&gt;
          {% children %}
        &lt;/ul&gt;
      {% endifchildren %}
    &lt;/li&gt;
  {% endnav %}
&lt;/ul&gt; 

&lt;ul&gt;


{# --- this is the key line here ---#}
{% if category is defined %}

{% set entries = craft.entries({
  relatedTo:  category,

})
%}

{% if craft.entries.relatedTo(category) %} 


      {% for entry in entries %}
        &lt;li&gt;  &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
      {% endfor %}
      &lt;/ul&gt;

     {% else %} 
    nothing to see
     {% endif %} 
     {% endif %}
</code></pre>

CC BY-SA 3.0
2018-04-19T20:36:37.133Z
Just a side note `{% if craft.entries.relatedTo(category) %}` will always become true, no matter what. There is no legit way to go to the else part
Robin Schambach
CC BY-SA 3.0
2018-04-19T18:13:31.263Z
2018-04-19T18:13:31.263Z
Andrew Hahn
<p>Here's the breakdown:</p>

<p>» <code>structure</code> with two <code>categories</code>. Each category has +10 entries. </p>

<p>» Template is <code>structure</code> / <code>index.html</code> and <code>_entryview.html</code> </p>

<p>I'd like to show two links and a description of both categories on the <code>/structure/</code> URL. </p>

<p>However...</p>

<p>On the <code>/structure/index/</code> page, I'd like to show the <code>entries</code> for each category — all using the same <code>index</code> template. </p>

<p>So far I can pull the <code>{category.title}</code>s and the <code>{entry.title}</code> ... but it's the same on both pages (<code>structure/</code> and <code>structure/category</code>)</p>

<pre><code>{% set categories = craft.categories.group('fellowsCat') %}

 &lt;ul&gt;
  {% nav category in craft.categories
    .group('fellowsCat')
    .limit(11)
    %}
    &lt;li&gt;
      &lt;a href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;
      {% ifchildren %}
        &lt;ul&gt;
          {% children %}
        &lt;/ul&gt;
      {% endifchildren %}
    &lt;/li&gt;
  {% endnav %}
&lt;/ul&gt; 

&lt;ul&gt;

{% set entries = craft.entries({
  section:  'fellows',
  relatedTo:  craft.categories('fellowsCat'),
})
%}


{# ___________________________
this is where things fall apart. 
If I'm on /structure/ I don't want to see entries. 
If I'm on /structure/category, I do. 
_____________________________
#}


{% if craft.categories is not null %}

  {% for entry in entries %}
    &lt;li&gt;  &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
  {% endfor %}
  &lt;/ul&gt;

{% else %}
nothing to see
{% endif %}
</code></pre>

<p>I suspect there's something with the <code>{% if craft.categories is not null %}</code> line that would do the job, but I can't figure it out. </p>

<templating><entry><category>
How to hide {{ entry.title }} on a {structure} page but show it on a {structure}/{category-slug} page
# How to hide {{ entry.title }} on a {structure} page but show it on a {structure}/{category-slug} page

(Asked by: username_0 on 2018-04-19)

Here's the breakdown:
» structure with two categories. Each category has +10 entries. 
» Template is structure / index.html and _entryview.html 
I'd like to show two links and a description of both categories on the /structure/ URL. 
However...
On the /structure/index/ page, I'd like to show the entries for each category — all using the same index template. 
So far I can pull the {category.title}s and the {entry.title} ... but it's the same on both pages (structure/ and structure/category)
{% set categories = craft.categories.group('fellowsCat') %}

 
  {% nav category in craft.categories
    .group('fellowsCat')
    .limit(11)
    %}
    
      {{ category.title }}
      {% ifchildren %}
        
          {% children %}
        
      {% endifchildren %}
    
  {% endnav %}
 



{% set entries = craft.entries({
  section:  'fellows',
  relatedTo:  craft.categories('fellowsCat'),
})
%}


{# ___________________________
this is where things fall apart. 
If I'm on /structure/ I don't want to see entries. 
If I'm on /structure/category, I do. 
_____________________________
#}


{% if craft.categories is not null %}

  {% for entry in entries %}
      {{ entry.title }}
  {% endfor %}
  

{% else %}
nothing to see
{% endif %}

I suspect there's something with the {% if craft.categories is not null %} line that would do the job, but I can't figure it out.

**Tags:** templating, entry, category


---

## 1 answers

### Answer by username_0 on 2018-04-19. Score: 1

Figured it out. 
    {% set categories = craft.categories.group('fellowsCat') %}

 
  {% nav category in craft.categories
    .group('fellowsCat')
    %}
    
      {{ category.title }}
      {% ifchildren %}
        
          {% children %}
        
      {% endifchildren %}
    
  {% endnav %}
 




{# --- this is the key line here ---#}
{% if category is defined %}

{% set entries = craft.entries({
  relatedTo:  category,

})
%}

{% if craft.entries.relatedTo(category) %} 


      {% for entry in entries %}
          {{ entry.title }}
      {% endfor %}
      

     {% else %} 
    nothing to see
     {% endif %} 
     {% endif %}

> **Comments:**
> **username_1**: Just a side note `{% if craft.entries.relatedTo(category) %}` will always become true, no matter what. There is no legit way to go to the else part  

---

