DEV Community

Ryan Westlund
Ryan Westlund

Posted on

How can I tell if my canonical URLs are working?

I crosspost a lot of articles from my own website to my blog here, and when I started doing it I learned about canonical URLs. I set them on all of the articles that are crossposts.

But I recently learned from Google's search console that one of my own internal links to an article with a query string telling it to load only a subtree of the comments is not counted as the same article! I saw that Google saw my declared canonical, and decided it wasn't right. I guess it made a pretty big difference in content given the number of comments on that one. That made me pretty concerned that the same thing is happening here, but since I don't have a domain property or a way to upload the required text files for URL prefix verification, I can't check.

During the writing of this, I found out about <article>. That's probably why my internal link wasn't working, I thought. Darn. I fear a lot of my canonicals weren't working either because I wasn't using that tag. (It looks like at least 4 of them were, but for the ones that weren't, I couldn't tell if it was because of this or if Google just hadn't crawled them yet.)

So I went ahead and changed my article template to use <article> instead of <div class="content">. Unfortunately, I know it could be months before Google recrawls them...

I inspected the HTML and found that the <article> encompass the title header. Is that normal? On my website, the article title is only displayed on the navbar (which also contains things like the dark mode switch). Should I put the navbar inside the <article>? I just have no way of knowing whether the canonicals are working, so I'm grasping at straws.

Discussion (1)

supunkavinda profile image
Supun Kavinda

How Google uses canonicals is confusing. Sometimes, even you add canonical URLs to Medium or posts, Google shows the Medium or post instead of your post in the search results. I personally faced this issue and the solution I found was, publishing on those platforms after 1-2 weeks.

And, yeah, even if you have comments section with canonical to the post, sometimes both are shown in the results. However, you won't get a penalty for duplicate content.

However, I'm sure if HTML tags have to do something with canonical URLs. It's the first time I heard it. I'd like to know more about it.