Promoting the stable version of the documentation using rel=canonical

I was thinking about documentation SEO today. Like many projects, Datasette offers multiple versions of the documentation:

For other projects that do this I've often found myself running a Google search and landing on on older version of their documentation. How best to avoid that?

I started by looking at how Django addresses this. Django uses rel=canonical - so, on this page: https://docs.djangoproject.com/en/2.2/topics/db/ they have the following HTML:

<link rel="canonical" href="https://docs.djangoproject.com/en/4.0/topics/db/">

I tend to default to imitating Django, so I decided to see if I could do that for the Datasette documentation...

... and found out it's already solved for me! Read The Docs, the platform I use for the Datasette documentation, already implements exactly this pattern.

So https://docs.datasette.io/en/0.50/introspection.html includes the following HTML:

<link rel="canonical" href="https://docs.datasette.io/en/stable/introspection.html" />

Here's their documentation covering this feature. I think you need to have configured a "default version" (though they may set a sensible default for that already) - for my project the page for doing that is the Advanced settings page at https://readthedocs.org/dashboard/datasette/advanced/

This TIL started life as a Twitter thread.

Created 2022-01-20T15:15:38-08:00 · Edit