The importance of canonical URLs

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
No comments yet. Be the first to comment.
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

I noticed I'm always talking about canonical tags when advising fellow bloggers, but I never wrote this down on paper.
So here we go, an article explaining why you should always use canonical tags when republishing your content elsewhere.
Let's first set a use case.
You are reading this article from one of the following three sources.
All these three sources have the same content. Now our good friend Google comes into play, and it wants to help people find the correct answer to their questions.
Let's say your blog does just that. How does Google know which blog to redirect to?
If you don't provide a canonical tag, Google might even think you are spamming the internet and not showing any of the three sites!
However, you can use this canonical tag to set which site is the primary source for this article.
So what do I do, you ask? I use my blog as my primary source of truth. It's what I want to rank on Google in the long term.
So how do we set these canonical URLs
If you are not using a custom website as your primary source, you can set the canonical URL by adding the following tag in your HTML head.
<link rel="canonical" href="https://daily-dev-tips.com/your-article-name" />
This will tell the search engines they can find the original content on the address you provide there.
Most blogging platforms offer a more visual way of adding these canonical tags.
For instance, on Hashnode, they have the following widget in the sidebar.

And the same kind of graphical element exists on dev.to.

A small side note is that my good friend Graham suggests you wait two weeks before reposting your content. He says it could happen that Google will crawl Hashnode before yours and rank that content higher.
This is, in theory, true. I don't follow the advice and have yet to experience this happen, but I want to put it out as a disclaimer, as multiple sources advise.
Reposting content is a great way to reach a broader audience, but it can hurt your SEO if you don't use canonical tags.
Do use canonical tags to indicate to search engines which is your original content.
Do not mix the canonicals to link to different articles from different sources.
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter