惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 聂微东
宝玉的分享
宝玉的分享
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
博客园 - 【当耐特】
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
博客园 - 司徒正美
博客园 - Franky
爱范儿
爱范儿
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
量子位
博客园 - 叶小钗
博客园_首页
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

Example blog

Ghost routing explained with routes.yaml examples — routes, collections & taxonomies Ghost redirects explained with practical redirects.yaml examples How to Serve JSON or XML Data in Ghost How to Change Your Default Post Template in Ghost Ghost Custom Theme Settings How to add Google Fonts to Ghost Themes How to Configure Ghost with Mailgun Ghost Theme Structure & Organization How to Make Custom Templates in Ghost Themes How to Install Ghost CMS via Ghost-CLI How to Add Syntax Highlighting to Ghost The best Ghost CMS hosting platforms Ghost 6.0 — Social Web and Native Ghost Analytics Ghost CMS Social web beta, email 2FA and more author social links How to keep custom design settings when updating your Ghost theme How to use the public preview card in Ghost How to add members-specific sections in Ghost How to customize the default content CTA in Ghost How to build a custom homepage in Ghost An overview of Ghost editor cards and and how they work Ghost CMS News: One-time payments & collecting sales tax How to customize the private site access template in Ghost How to add custom fonts in Ghost themes Ghost CMS News: Additional payment methods & internal linking How to use Code Injection in Ghost Ghost CMS News: TK reminders, ActivityPub and improvements How to format dates and use the date helper in Ghost Ghost CMS internationalization, custom fonts & spam protection Understanding and optimizing post and page settings in Ghost CMS Trigger the Ghost Portal popup based on page scroll progress
How to set meta data of your custom routes & collections ...
Bright Themes · 2024-06-16 · via Example blog

Ghost is very practical and makes it easy to create custom routes and collections, allowing you to tailor your content and optimize it for search engines and social media platforms through meta data settings.

The main steps for setting the meta data for your custom routes and collections:

  1. Add the data property to the route or collection with the page slug.
  2. Create the page with the slug you specified earlier.
  3. Add the meta data in your page settings.
  4. Upload the new routes.yaml file.

Now, we'll go into more details and also give you some examples of how you can set meta data for custom routes and collections in Ghost.

The two main types of content relevant for setting meta data are pages and tags. In the context of Ghost, pages are the backbone of your website, acting as static elements that convey critical information. Tags in Ghost are a powerful organizational tool, grouping related content together.

For more details check out our detailed overview of page settings, going beyond meta data.

When talking about meta data in pages and tags, you can set the following extra context for search engines:

  • Meta title — set a different title for search engines. In Ghost, the recommended length is up to 60 characters for pages and 70 characters for tags
  • Meta description — set a different description for search engines. In Ghost, the recommended length is up to 145 characters for pages and 156 characters for tags
  • Canonical URL — To prevent search engines from indexing duplicate content, specify the canonical URL. This is crucial for maintaining a coherent and effective SEO strategy

Beyond these settings, you can set X (Twitter) and Facebook specific information like: title, description, and image.

Now that we have an understanding of the settings, let’s see how these can be applied when using custom routes.

Custom routes, collections, and channels

Before delving into the meta data settings, let's revisit the fundamentals of custom routes and collections in Ghost. Custom routes enable you to create unique URLs for specific pieces of content, offering a personalized navigation experience for your audience. Collections and channels, allow you to group related content, shaping the way it's presented on your site.

Creating custom routes and collections involves utilizing the routes.yaml file in your Ghost theme. This file acts as a configuration hub, letting you define the structure and organization of your content. Each route and collection can be tailored, giving you the option to set: permalink, template, filter, and data.

We won’t go into more details on all of that as we have covered it before, in our Dynamic routing and routes.yaml post, but next we will look into the data property.

Data property in routes and collections

Collections and routes accept a data property, which will pass in the data to the collection or route.

Let’s look at an example to understand this. You might have a portfolio and blog collection. here’s how you can set the title, description, and meta data for these collections. Here’s the routes setup:

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

Let’s look at each collection separately:

  1. The blog collection will have all posts with the blog tag, and the title, description as well as meta data will all come from the blog tag. With this setup, the blog tag will redirect to the /blog/ page. To control the meta settings go and edit them from the tag settings.
  2. The portfolio collection will have all posts with the case study or project tag. In this case, the meta data is sourced from the /portfolio/ page instead of the tag. To control the meta settings go and edit them from the page settings.

Too many redirects

As with all settings you have to be careful and look out for some common issues you might experience in case your settings and data don’t match.

If you face an ERR_TOO_MANY_REDIRECTS on a collection route that’s likely from one of your collections where you specified the data property but the corresponding page was not created.

For example, if I have the portfolio collection from the above example, I need to have a page with the /portfolio/ URL, otherwise, it will end up in a redirect loop.


Following this guide, you can create custom routes and collections and at the s ame time control the meta data either via pages or tags to have tighter control and optimize your SEO.