Ghost Routing with Collections

Ghost Routing with Collections

When converting a site that may be serving content with a date based URL, something like {domain}/{path}/{year}/{month}/{slug}/, it makes sense to retain the existing structure when porting content; the old content is indexed by the likes of Google, Yahoo, Microsoft. Getting existing content re-indexed is a nightmare, if it is even possible. One possible way to fix this issue is to setup redirects, which are generally expensive, a lot of work, and generally causes issues of their own.

When migrating your content to Ghost, we can easily setup dynamic routes, which allow for content to be created in a native format but responsive to the old URL layout without having to setup exhaustive redirects.

With a simple collection, both the common slug and a date based slug can be used simultaneously.

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

This very collection is used on https://cloudnull.io, which allows this post to use the simple slug and a date based slug, and my older content to retain its current date based URL; all URLs have a single permanent link which is great for SEO.

Here's an actual example of how this is working with some older content.

This simple setup allows for a smooth migration to Ghost from a platform like Drupal or WordPress without having to deal with complicated server-side redirects or other platform migration tactics. The power of Ghost's builtin routing capability is nearly endless and just one of a million reasons why Ghost is a spectacular platform.

Mastodon