Include year and month in Ghost blog post permalinks

Woman, with her back to a river, studying a paper map.
How do I get to this blog post?

This is especially useful if you migrated your posts from WordPress to Ghost and want to keep most of your blog post URLs the same.

If you go to Settings > Labs, click on Download current routes.yaml within the Beta Features > Routes section at the very bottom.

Open that file and it should look something like this:

routes:

collections:
  /:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

Save a copy of this file as a backup, so you know how to revert the change in the future, should you change your mind.

In order to include the year and month in your blog post URLs, we're going to adjust the permalink structure as follows:

routes:

collections:
  /:
    permalink: /{year}/{month}/{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

Now save that file, click the Upload routes YAML button, and select that file.

If you visit a blog post now, you should see the year and the month in the URL.

Featured image by Nick Seagrave.