Is it possible to cumulate slugs (tags) under 1 link?

I have yet to work with routes, so bear with me here.

Say I had some posts about different topics of math with different tags, e.g. calculus and linear algebra. Can I make a slug/tag that cumulates all the posts from both tags and make it a link on the nav bar? For an example, a link to a tag “Math” that contains both posts from the calculus and linear algebra tag.

An example would be great! Keep in mind I haven’t modified the routes.yaml file before, so it should be completely as is from the start.

Howdy there! You can absolutely do this with the help of Channels. Don’t fear the routes file, it’s can be extremely powerful. Here’s an example using the example concept you mentioned:

    controller: channel
    filter: tag:[calculus, algebra]

Add this to your routes file, and then create a new math.hbs template that uses a similar post loop structure as shown in your main index.hbs file.

This will create a new /math/ page which lists all posts that match the tag filter criteria, aka any post tagged with “calculus” or “algebra”.

Hope this helps! :rainbow:

1 Like

Thank you!

But how do I configure it like a tag, e.g. title, background image, spacing between header and main without having to copy the whole default in there. Obviously, it would slow down the performance if I were to copy the default handlebars code into the math handlebars.

I see that you can use #tag and /tag, but when I try that, it obviously doesn’t work. Is there a way to add a template, like for tags?

With the method I mentioned you could use a regular page to append content to the math.hbs page, such as title, image and other content. Either that or create a new parent tag like you mentioned before. There’s a few ways to do this, depends how you want to do it :slightly_smiling_face:

This does not really seem satisfactory. Because now I’m missing meta data and there is this padding of 40px for the page. I tried using data and template in the routes file, to be able to add some of the meta data. But it’s not complete, so I’m not sure how to go about it.

Which metadata are you missing? The padding can be solved with CSS. The name of the template should match the route you’ve created in the routes file, so the in the example it would be math.hbs. Then inside of that template you’ll need to make sure that there’s a post loop to show posts, as well as a get to get the content of the page so you’ll have the right metadata in there. There’s documentation here on the get helper: