Answers.Body: <p>Your blog variable is an <a href="https://craftcms.com/docs/templating/elementcriteriamodel" rel="nofollow">ElementCriteriaModel</a>, which can be treated like an iterable array:</p>
  
  <pre><code>{% if blog|length %}
      Content
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-28T17:05:36.250Z
Answers.LastActivityDate: 2016-05-28T20:36:18.027Z
Answers.LastEditDate: 2016-05-28T20:36:18.027Z
Answers.UserDisplayName: Patrick Harrington
Body: <p>I've got a blog section on a page but want to hide it if there are no blogs. </p>
  
  <pre><code>{% set blog = craft.entries.section('blog').limit(5) %}
  {% if blog !='' %}
    &lt;div class="something"&gt;
      {% for entry in blog %}
        ...
      {% endfor %}
    &lt;/div&gt;
  {% endif %}
  </code></pre>
  
Tags: <templating><conditional>
Title: How do I write a conditional for whether a section contains entries?
ThreadText: # How do I write a conditional for whether a section contains entries?
  
  (Asked by: username_0 on 2016-05-28)
  
  I've got a blog section on a page but want to hide it if there are no blogs.
  
  ```
  {% set blog = craft.entries.section('blog').limit(5) %}
  {% if blog !='' %}
    <div class="something">
      {% for entry in blog %}
        ...
      {% endfor %}
    </div>
  {% endif %}
  
  ```
  
  **Tags:** templating, conditional
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-28. Score: 6 | Accepted answer
  
  Your blog variable is an [ElementCriteriaModel](https://craftcms.com/docs/templating/elementcriteriamodel), which can be treated like an iterable array:
  
  ```
  {% if blog|length %}
      Content
  {% endif %}
  
  ```
  
  
  ---
  
  