Add Custom Canonical Link

What is a Canonical Link?

A canonical URL is a simple solution for duplicate content. If you write, for example, a new port on LinkedIn and you want to have the same article on your website but you want to avoid duplicate content, you can edit the canonical link on your website and point to the LinkedIn post.

https://www.linkedin.com/pulse/become-coach-six-fundamentals-professional-coaching-john-c-maxwell/
https://yourdomain.com/become-coach-six-fundamentals-professional-coaching-john-c-maxwell/

If these URLs are both for the same post, choosing one as the canonical URL tells Google and other search engines which one to show in the search results.

Canonicals also enable you to point search engines to the original version of an article.

Here is how the Canonical META looks like in our example:

<link rel="canonical" href="https://www.linkedin.com/pulse/become-coach-six-fundamentals-professional-coaching-john-c-maxwell/" />

Custom Canonical URL with Squirrly SEO

With Squirrly SEO plugin you can customize the Canonical using the Squirrly SEO Snippet or by calling the sq_canonical hook in your code.

To edit the Canonical URL using SEO Snippet follow the instructions from this URL: 
https://howto.squirrly.co/kb/bulk-seo/#bulk_seo_snippet_metas

Custom Canonical URL using Filter Hook

To edit the Canonical URL using the sq_canonical hook, activate Squirrly SEO plugin and add this code in function.php file:

//Hook the Squirrly sq_canonical
add_filter('sq_canonical', 'custom_squirrly_canonical', 11);
function custom_squirrly_canonical() {
    global $post;

    if($post->ID == '{post id}'){
        return 'the external canonical link';
    }
}

Just replace the { post id } with your WordPress post ID and the external canonical link with the real post link.

Was This Article Helpful?

0 Comments

There are no comments yet

Leave a comment

Your email address will not be published. Required fields are marked *