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

distill

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

Author
Published

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. cararthompson.com/blog/the-post-in-question. 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:

canonical_url: https://exampleoriginalsite.com/the-original-post/

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.
author:
  - name: Cara Thompson
    url: {}
date: 2022-01-24
output:
  distill::distill_article:
    self_contained: false
canonical_url: https://rfortherestofus.com/2022/02/data-viz-org-branding/
categories:
  - 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.

Reuse

Citation

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. https://www.cararthompson.com/posts/2022-05-30-credit-where-its-due-changing-the-canonical-url-of-a-post/credit-where-its-due-changing-the-canonical-url-of-a-post.html.