On this page
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:
- Add
datato the route or collection, with the slug of a page or tag. - Create that page, or use that tag.
- Fill in its metadata in Ghost Admin.
- 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:
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 taggedblog, 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 taggedcase-studyorproject. 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.
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.