Home

Global Content IDs to Minimize Risk in Changing URLs

Use a unique value within a URL and make the rest arbitrary. This way you have flexibility to change URLs without breaking functionality for your visitors.

I do most of my writing in Notion these days, and I've recently paid closer attention to how URLs change as I change content. Take a look at this:

Notice that the URL includes the title of the page at first. When I erase it, there's a long obscure value. And when I add a new title, the title begins to appear in the URL, with the obscure value appended to the end.

Global Content ID Explained

What Notion is doing is apply a global ID value to this particular page. It doesn't matter what the page's title is. The content ID is always going to be attached to the page.

It can be nested anywhere. Moved to another database. Deleted. Doesn't matter. The ID stays the same.

Applying Global IDs to Your Site

You can do the same thing with the pages on your site. How this works depends on your web framework and content source(s). But, generally speaking, it's possible.

In most cases, you would parse the end of the URL (for example, all characters after the last dash) and use that to match the appropriate content.

Building Arbitrary URLs

The result of this practice is that (depending on your setup) the URL segments are essentially meaningless. You (or your content editors) can change them, and it doesn't matter. You're still going to be able to find the correct page and render it.

Accounting for SEO

There is a side effect to this approach, which is that you can then have an endless number of URLs for any given page. That's great for delivering content, but not so great for long-term SEO value. You still want Google to think you only have a single URL for a given page.

Therefore, I'd suggest having a single go-to URL for each page, and being diligent when changing URL values for any given page.

Let's Connect

Keep Reading

Never Lose Copied Text Again!

If you’re constantly copying and pasting and losing what is on your clipboard, here’s the perfect solution!

Dec 13, 2022

Transforming Unsplash Images

Unsplash uses Imgix to serve its images, which means you can transform the images before downloading.

Dec 08, 2022

Run a Single Jest Test

Learn how to run a single test within a file, how to target a series of tests within a file, or how to only target a single file when using Jest.

Jun 04, 2022