Separate channels by author depending on tag?

  • What version of Ghost are you using?

I have two different types of content on our site, articles and podcasts. I would like /author/<author_slug>/ to show a channel of posts not containing podcasts and /podcaster/<author_slug>/ to show a channel of posts only containing podcasts. I’m able to achieve this using:

    controller: channel
    filter: tag:-podcasts+author:author-slug
    template: author

    controller: channel
    filter: tag:podcasts+author:author-slug
    template: author

The problem is this is hardcoded and would have to be included for every new author/podcaster. Is there a way to pass in the second portion of the path into the filter and data fields? Or is there a better way to accomplish what I’m trying to do?

Could you not take a simpler approach and use the #get helper on author pages to group posts by whether it’s a post or a podcast? That way you could link to podcasts with /author/author-name/#podcasts and posts with /author/author-name/#posts

Hmm, that’s one option. I’m not sure we’d want both collections on the same page however. I guess I could build separate templates for /author/author-name and /podcaster/author-name and use #get helper there. How would I filter by author in this case?

Is there no way to capture a parameter in a route and pass it into the filter and data fields?

Alternatively, how would one pass the last portion of a path to a template? In my use case it would be /author-name.

Just wondering about this point, are you planning on having many authors and podcasters? :slight_smile:

Yes, though “many” is relative. I’ve limited the hardcoded routes to individuals that have participated in podcasts and have written articles. It’d be very handy to be able to set a route and capture a portion of the path and pass it into the template, that way the template can automatically filter for that author’s posts and for a specific tag without having to use the route’s filter mechanism manually.

With the default Ghost routes file you get an author page out of box. Are you setting up your own podcast? I’d be inclined to add the podcaster route whenever they need it. I’m anticipating your podcast won’t be as frequent as your articles :slight_smile:

I get why you might want to automate this kind of routing, you might not actually need it once all your authors and podcasters are set up

Yes I have an author template as well but it will not filter out posts with tag podcasts. So I am using routes to filter the list of posts that the author template will iterate over. If taxonomies support a filter arg that would be great but afaik they do not. Thus it seems that routes are my best option.

We have had a podcast for a couple years now, our org has been creating podcasts and writing articles for 2 years so we have a decent # of episodes and articles. Our podcast is relatively frequent, at least one a week sometimes more depending on how time-sensitive the topics are. In addition we have bonus podcasts that we unlock after a period of time.

The bigger issue is that to allow our users to search by podcaster we need pages for every regular guest (which grows slower than the rate of podcasts but will grown nonetheless). The bottom line is that manually hardcoding it is feasible for now but when looking forward, a more scalable solution is desirable.

I see. Thanks very much for sharing more about the type of site you’re trying to create, helps us get a better picture of what your goals are and what people are trying to create with Ghost.

Have you considered using Ghost as a Headless CMS? With the Ghost Content API you have a lot more room to scale up, letting you query the content more precisely and create routes in a far more dynamic fashion. Static Site Generators like Eleventy will let you create routes for any kind of subset data you want. I could certainly see this working for a site like yours. I fairly recently created an Eleventy starter that uses the Ghost API, in the main .eleventy.js file you’ll see how I’m generating “collections” such as posts and pages. You could create new collections called “podcasters” and filter the podcasts into their respective podcaster pages.

I realise this may seem overwhelming to someone who hasn’t used these types of tools before, but I can see that your usecase is beginning to enter into a far more complex domain. Happy to provide some guidance on how to create those additional routes for you :smiley:

Yes I’ve been considering using Ghost headlessly as I’ve been noticing the limitations of the built-in templating system. I appreciate your offer, I’ve been looking static site generators, right now Gatsby is probably at the top of my short list of potential options to investigate. I haven’t used a static site generator before but I do have enough experience working with React and it’s toolchain to feel comfortable.

That’ll be a future project probably, our current implementation works for now. I’d rather not introduce additional complexity at this point. Your suggestions are appreciated.

Sounds like you’ve made some good considerations. I wish I could help more but I think with your project you’re reaching the limitations of the built-in theming layer and will need to step out with Gatsby or something similar. For now maybe my original suggestion of grouping articles and podcasts together on the author page is a decent compromise?

We wanted to keep them entirely separate so your suggestion doesn’t meet our needs unfortunately. I’ve gone and manually set routes for all the authors and podcasters that need them so we have found an implementation that is sufficient for now.

I appreciate your efforts to work with me to find a more suitable solution. Thanks!

1 Like