Skip to content

40%off everything for Black Friday, with code . Until Dec 1.

Bright Themes

How metadata works for routes and collections in Ghost

Custom routes and collections have no settings of their own in Ghost Admin. The data property borrows them from a page or a tag, so you can set their meta title, description and social cards.

Norbert2 min read

A custom route or collection in routes.yaml has no settings screen in Ghost Admin, so it has no meta title or description of its own. The data property fixes that: it links the route to a page or a tag, and the route uses that page’s or tag’s metadata for search engines and social sharing.

In short:

  1. Add data to the route or collection, with the slug of a page or tag.
  2. Create that page, or use that tag.
  3. Fill in its metadata in Ghost Admin.
  4. Save the new routes.yaml.

The metadata you can set

Pages and tags both have these settings, in the page’s settings panel and on the tag’s page in Tags:

  • Meta title: the title search engines show. Ghost recommends up to 60 characters for pages and 70 for tags.
  • Meta description: the description search engines show. Ghost recommends up to 145 characters for pages and 156 for tags.
  • Canonical URL: the original address when the same content is published somewhere else, so search engines don’t treat it as a duplicate.
  • X card and Facebook card: the title, description and image used when someone shares the link.

The post and page settings explainer covers these fields in detail.

The data property

Routes, collections and channels in routes.yaml can all take data. Its value is the resource type and the slug: page.portfolio is the page with the slug portfolio, tag.blog the tag with the slug blog. (New to routes and collections? Start with how routing works in Ghost.)

Two collections, one with its metadata from a tag and one from a page:

YAML
collections:
  /blog/:
    permalink: /blog/{slug}/
    template: blog
    filter: tag:blog
    data: tag.blog
  /portfolio/:
    permalink: /portfolio/{slug}/
    template: portfolio
    filter: tags:[case-study,project]
    data: page.portfolio
  • /blog/ lists every post tagged blog, and its title, description and metadata come from the blog tag. Edit them in the tag’s settings. The tag’s own archive, /tag/blog/, now redirects to /blog/, so there is one URL for that list.
  • /portfolio/ lists the posts tagged case-study or project. Its metadata comes from the portfolio page, since neither tag describes the whole collection. Edit it in that page’s settings.

A tag suits a collection that is one tag. A page suits everything else: a collection of several tags, a custom route such as /about/ (see custom pages), or a homepage. A page also gives you a title, feature image and content to show in the template, inside {{#page}} … {{/page}}.

Edit routes.yaml in Settings › Advanced › Labs › Beta features, with Edit in the Routes row.

Settings › Advanced › Labs › Beta features

Check the metadata a route uses by viewing the page source, or with a link preview tool. For the full walkthrough of a homepage built this way, see how to build a custom homepage in Ghost.

Related posts

More on SEO

Get the Bright Themes newsletter

New tutorials and explainers, what changed in Ghost, and our theme releases. No spam, unsubscribe anytime.

Get the Bright Themes newsletter

New tutorials and explainers, what changed in Ghost, and our theme releases. No spam, unsubscribe anytime.