Credit where it’s due: changing the canonical URL of a post


A quick change in the YAML header to keep the search engines happy.


May 30, 2022

A shelf of identical tins of Campbell’s Soup | Photo by Kelly Common on Unsplash

As part of my consultancy work, I’ve written blog posts that have appeared on other sites. I repost most of them here, but when the post has been written on client time, it’s only fair that they should get the traffic from any Google searches that lead to the post I wrote for them.

How can I make sure that’s what happens? It’s all down to providing the right canonical URLs.

The what now?

A “Canonical url” is “the URL of the best representative page from a group of duplicate pages”. Its purpose is to make clear to the search engines which page should be credited as the original of several duplicate pages.

The default behaviour of {distill} is to make the canonical URL the one which is within my blog, e.g. If I leave that as is, I’m creating URL that competes in search engines with the client’s URL.

How do we change that?

Within the YAML section at the start of the post, add the following:


One of the ones for which I did this was my post on creating and applying bespoke colour schemes. I wrote it for R for the rest of us, so I want the search engines to point folks to R for the Rest of Us, not to me. Here’s the full YAML for that post on my site:

title: "How to make data viz that matches your organisation’s branding"
description: |
  A short description of the post.
  - name: Cara Thompson
    url: {}
date: 2022-01-24
    self_contained: false
  - design
  - ggplot

Give it a whirl!

If you google “How to make data viz that matches your organisation’s branding”, the first url you get is the one on the R for the rest of us blog. Looks like it worked, even though I stuck to British spelling in my own version of the post. Good to know!

Further reading

For more details and other related options, check out the official {distill} guidance on importing blog posts.



For attribution, please cite this work as:
Thompson, Cara. 2022. “Credit Where It’s Due: Changing the Canonical URL of a Post.” May 30, 2022.