Empty page.collection - What am I doing wrong?

I want to build a news-Feed, like a blog. My problem is that the page.collection is always empty, but I did as all the documentation and examples told me to. I must miss something, but I can not finde my mistake.

My folder structure looks like:

This ist the structure of the blog.md

---
title: News
content:
    items: @self.children
    limit: 5
    order:
        by: date
        dir: desc
    pagination: false
    url_taxonomy_filters: false
---

And this is the structure of the blog.html.twig

{% extends 'partials/base.html.twig' %}

{% block content %}
    <section id="body-wrapper" class="main style3 primary">
        <div class="content container">

            **{{ var_dump(count(page.collection)) }}**

            <div class="uk-child-width-1-3@m uk-grid-small uk-grid-match" uk-grid>

                {% for child in page.collection() %}
                    <div>
                        <div class="uk-card uk-card-default">            
                            <div class="uk-card-header">
                                <div class="uk-grid-small uk-flex-middle" uk-grid>
                                    {% set image = child.media.images|first %}
                                    {% if image %}
                                    <div class="uk-width-auto">
                                        <a href="{{ child.url }}"><img src="" uk-img>{{ image.cropZoom(800,400).html|raw }}</a>
                                    </div>
                                    {% endif %}
                                    <div class="uk-width-expand">
                                        <h3 class="uk-card-title uk-margin-remove-bottom">{{ child.title }}</h3>
                                        <p class="uk-text-meta uk-margin-remove-top"><time datetime="{{ child.date|date("c") }}">{{ child.date|date(system.pages.dateformat.short) }}</time></p>
                                    </div>
                                </div>
                            </div>
                            <div class="uk-card-body">
                                <p>
                                    {% if child.summary != child.content %}
                                        {{ child.summary|raw }}
                                    {% else %}
                                        {{ child.content|raw }}
                                    {% endif %}
                                </p>
                            </div>
                            <div class="uk-card-footer">
                                <a href="{{ child.url }}" target="_blank" class="uk-button uk-button-text">Weiterlesen</a>
                            </div>
                        </div>
                    </div>
                {% endfor %}
                
            </div>
        </div>
    </section>
{% endblock %}

The {{ var_dump(count(page.collection)) }} shows always int(0).

Has anybody a hint for me?

Your folder structure shows, that _ndr and _news are modular pages. In order to list modular pages, instead of @self.children, you need to define collection like:

content:
    items: '@self.modular'

It depends what you’re trying to achieve here - modules are not meant to be blog items :thinking: You should use normal templates instead of module

@machtelik, Considering you are using 05.news/blog.md, its blog oriented collection definition, and 05.news/_ndr/item.md you are aiming to use the blog-style way of listing items and not a modular page.

In that case, you seem to have done everything OK, except for the underscore in front of the folder names.

According the docs: Pages: Folders:

Modules are identified by an underscore ( _ ) before the folder name. This is a special folder type that is intended to be used only with modular content . These are not routable and not visible in the navigation.

You guys are the best. I am pretty new to Grav, but i guess you already figured that… :slight_smile: