Showing pages that are published

I have a template that is displaying a list of children, but the output also shows pages that are have “published: false”.

<ul class="list-group">
    {% for p in page.children if p != page %}
         <li class="list-group-item"> <a href="{{p.url}}"><i class="fa fa-angle-right" aria-hidden="true"></i> {{ p.title }}</a></li>
    {% endfor %}
</ul>

How do I exclude unpublished pages?

Hi
The page collection includes a “published” boolean so something like this should do what you need:

{% if p.published %} 
{% endif %}
1 Like