Skip to contentSkip to main navigation Skip to footer

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 post on LinkedIn and you want to have the same article on your website but strive to avoid duplicate content, you can edit the canonical link on your website and point to the LinkedIn post.

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="" />

Custom Canonical URL with Squirrly SEO

With the 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 the BULK SEO feature, follow the instructions from this URL >>

Custom Canonical URL using Filter Hook

To edit the Canonical URL using the sq_canonical hook, activate the 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?