Channels/Collections/Routing Issue

I’ve been at it for a few days, I can’t seem to figure it out. Here is what I’m trying to do. I want to create a channel/collection for blog and gaming but everything else stays within the root page.

routes:

routes:
  /:
    controller: channel
    template: index
    filter: tag:-[gaming,blog,news]

collections:
  /gaming/:
    permalink: /gaming/{slug}/
    template: index
    fliter: tag:[gaming]
    data: tag.gaming
  /blog/:
    permalink: /blog/{slug}/
    template: index
    fliter: tag:[blog,news]
    data: tag.blog

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

index.hbs:

{{!< default}}

<div class="gh-outer">
<main class="site-main gh-inner">

    {{#if @custom.show_featured_posts}}
        {{> "featured-posts"}}
    {{/if}}

    {{#get "tags" limit="all"}}
    <div class="topic-feed">

        {{#foreach tags}}
            <section class="topic">
                <header class="topic-header">
                    <h2 class="topic-name">
                        <a href="{{url}}">{{name}}</a>
                    </h2>
                </header>
                {{#get "posts" order="published_at asc" filter="tag:{{slug}}" limit="5" as |featured|}}
                    <ul class="topic-article-feed">
                        {{#foreach featured}}
                        <li class="topic-article">
                            <h3 class="topic-article-title">
                                <a class="topic-article-link" href="{{url}}">
                                    {{> "icons/chevron-right"}} {{title}}
                                </a>
                            </h3>
                        </li>
                        {{/foreach}}
                    </ul>
                {{/get}}
                <a class="topic-more" href="{{url}}">Show more →</a>
            </section>
        {{/foreach}}

    </div>
    {{/get}}

</main>
</div>

Basically, I can’t figure out the filtering and the tag/slug to save my life. I’ve googled and searched the forms. I’m wondering if it’s with my theme that I’m using that is preventing it but I can’t figure it out. I’m using a modified ease theme.

my page is https://mytecknet.com, https://mytecknet.com/gaming, Blog - myTeckNet

I’m a little unclear on what the final goal is. Can you say what you want to happen at the end of the day?

These are likely the docs most relevant to what you’re after:

I’ve referenced that page and still wasn’t able to get channels or collections to work appropriately.

I would like the main landing page to have all tags/slugs that are not gaming, blog, or news.
I would like content that is gaming to fall under the gaming collection, and blog or news to fall under the blog collection. If that makes more sense. I’ve tried the other methods from within the forum and other sites but unsure if its just the ease theme that is preventing this or I’m typing something wrong. I’m self-hosted and on version 5.69.0 if that helps.

I’ve looked at this tutorial Building content collections in Ghost as well as the Dynamic URLs and Routing but can’t crack the nutt.

In that case, you’d set up your routes file like this:

routes:

collections:
  /gaming/:
    permalink: /gaming/{slug}/
    filter: tag:gaming
  /blog/:
    permalink: /blog/{slug}/
    filter: tag:[blog,news]
  /:
    permalink: /{slug}/
    filter: tag:-[gaming,blog,news]

Keep taxonomies as is.

This will put all gaming posts on the gaming path, all blog or news posts on the blog path, and everything else on your default, root path. (Filter has a typo, too, in your original post, which might have contributed to your difficulty.)

I will give it a shot… and OMG spellcheck would have been nice in VSCode or at least letting me know common engrish was wrong. Thanks. Report back shortly.

Still no love for the following pages:
Blog - myTeckNet
Gaming - myTeckNet

I even restarted ghost

I’m starting to believe its the index.hbs now? Thoughts? This is where I have beating my head on.

Oh, right. I should’ve looked more closely at the index file. So, the routing should be right, but your theme doesn’t use routing to display posts on the homepage, which is why you’re having trouble.

The theme displays content based on your tags. You’ll need to rewrite your index.hbs file or try a different theme. You can switch to Casper, for example, to see if the routing is working as intended.

Figured as much, I’ll give that a shot with some tag and post filtering. Is there a guide/tutorial using route based themes that you can ref? I’ll look around myself as well.

Routing is the default behavior. Most tutorial/themes will work for you.

I haven’t tested this, but something like this will put you on the right track, but you’ll still need to adapt it to your needs.

<div class="topic-feed">
  <ul class="topic-article-feed">
    {{#foreach posts}}
    <!-- This is the default way to access posts -->
    <li class="topic-article">
      <h3 class="topic-article-title">
        <a class="topic-article-link" href="{{url}}">
          {{> "icons/chevron-right"}} {{title}}
        </a>
      </h3>
    </li>
    {{/foreach}}
  </ul>
</div>

figured it out while keeping the index.hbs.

I kept trying to use the tag in the filter but found it easier to use slug. Here is what I used:
{{#get “tags” filter=‘slug:-[gaming, blog, news]’ limit=“all”}}

{{!< default}}

<div class="gh-outer">
<main class="site-main gh-inner">

    {{#if @custom.show_featured_posts}}
        {{> "featured-posts"}}
    {{/if}}

    {{#get "tags" filter='slug:-[gaming, blog, news]' limit="all"}}
    <div class="topic-feed">

        {{#foreach tags}}
            <section class="topic">
                <header class="topic-header">
                    <h2 class="topic-name">
                        <a href="{{url}}">{{name}}</a>
                    </h2>
                </header>
                {{#get "posts" order="published_at desc" filter="tag:{{slug}}" limit="5" as |featured|}}
                    <ul class="topic-article-feed">
                        {{#foreach featured}}
                        <li class="topic-article">
                            <h3 class="topic-article-title">
                                <a class="topic-article-link" href="{{url}}">
                                    {{> "icons/chevron-right"}} {{title}}
                                </a>
                            </h3>
                        </li>
                        {{/foreach}}
                    </ul>
                {{/get}}
                <a class="topic-more" href="{{url}}">Show more →</a>
            </section>
        {{/foreach}}

    </div>
    {{/get}}

</main>
</div>
1 Like