Exclude tags from home article list

I am using the dawn theme and customised a few elements for my needs. I am using three main tags on my website: work, blog, and about-me. On home I need to exclude the tag blog for the post list. I tried with the code below and it’s partially working. It’s excluding the tag blog but at the same time it’s shower fewer articles for every blog entry with the tag blog. So what can I do to always show a fixed amount of posts?

<div class="content-area">
    <main class="site-main">
        <div class="post-feed container medium">
            {{#foreach posts}}
              {{#has tag="blog"}}
                  {{!-- show nothing nothing --}}
                  <p>1</p>
              {{else}}
                  {{> "loop"}}
              {{/has}}
            {{/foreach}}
        </div>
        {{pagination}}
    </main>
</div>

You can use the limit to set the post limit

{{#foreach posts limit="30"}}

Also the get helper could help you to filter the post properly.

I tried that. But the problem still exists. If I have 30 new articles with the tag blog the list would give me 0 results.

You could do that with the routes.yaml file, with the filter option.
Then in your index you don’t have to check as all posts with blog should be excluded.

The “/” collection should look something like this:

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: tag:-[blog]
1 Like

This works perfectly. Thank you bironthemes! I am wondering about one thing. I fiddled around with the routes.yaml which is placed in my theme root. And it had no effect at all. But I discovered there is another routes.yaml in content/setttings and that worked. Does the routes.yaml within the theme root have no meaning at all?

No, the routes files in the theme root is usually for tracking the changes of that file.
Whenever you change it you have to upload it in the Admin/Settings.