How to modify Custom Collection Title and Description?

#1

Using the Ghost blog routes.yaml file it is possible to use the collections block to create a custom collection made from some tag(s) and / or other data. You can also tell this collection to use a custom theme template see:

  1. https://docs.ghost.org/tutorials/creating-content-collections/
  2. https://docs.ghost.org/concepts/routing/#content-structure

For instance:

collections:
  /example/:
    permalink: /example/{slug}/
    controller: channel
    filter: tag:example-tag
    template:
      - example

All of the above works and my collection properly uses my new example theme file.

The issue is that unlike the tag page (for example-tag) my new custom collection does not have a readily documented way to work with the title etc.

It does not pull the title / meta description from the tag used to build the collection (which would be great for collections built from single tags). In an attempt to work around that I tried some {{#has}} statements but I can’t figure out what context the custom route would fit into.

With the above example routes.yaml the title for the custom collection ends up as ‘My Site Name (Page 1)’ — and there is no Meta Description.

This issue also extends into the Open Graph data which lists an identical title as well as no description for the custom collection.

My guess is that it may be possible to use a data property attached to the routes.yaml file to achieve this (see: https://docs.ghost.org/concepts/routing/#data) but I haven’t found a solution as of now.

Here’s hoping someone has run into this as Googling around came up surprisingly empty — also posted over to StackOverflow for that reason: https://stackoverflow.com/questions/54498762/how-do-i-set-ghost-blog-custom-routes-yaml-collection-title-meta-description-i

1 Like
#2

Response is written to your stackoverflow question: https://stackoverflow.com/a/54788950/466677