Skip to contentSkip to main navigation Skip to footer

Add Custom Canonical Link

Squirrly SEO Add Custom Canonical Link screen on a laptop

A canonical link tells search engines which address is the original of a page. Squirrly SEO writes <link rel="canonical"> with the page’s own URL, and you can point it to another URL from the SEO Snippet or with the sq_canonical filter.

Use a custom canonical when the same article lives at two addresses. For example, a post first published on LinkedIn and copied to your blog can name the LinkedIn URL as its canonical, so search engines show that one.

Before you start

The canonical needs Add Canonical Meta Link on in Squirrly > Technical SEO > SEO Metas. It is on by default and shows in SEO Expert mode. The Canonical link field of the snippet is also an SEO Expert mode field, so click SEO Expert at the top of any Squirrly screen first. SEO Metas explains the switch.

Set the canonical of one page

  1. Go to Squirrly > Optimize > Bulk SEO, or open the page in the editor and scroll to the SEO Snippet box.
  2. Click the METAs dot of the page, then Edit Metas.
  3. Paste the full original address in Canonical link.
  4. Click Save.

The hint under the field says “Leave it blank if you don’t have an external canonical”. An empty field keeps the page’s own URL. In Bulk SEO, the Canonical Link task turns red while the canonical points to another URL, so you can find those pages later with Filter by Red Element.

The page source then shows the line, for example:

<link rel="canonical" href="https://www.linkedin.com/pulse/your-article/" />

Squirrly removes any other canonical, prev and next links from that page, so only its own canonical stays.

Example on the demo store

Leave Canonical link empty on a normal page: the field shows the URL Squirrly finds by itself, and that URL goes into the page source.

Squirrly SEO snippet Meta Tags tab with Title, Meta Description, Meta Keywords and Canonical link
The Canonical link field shows “Found:” and the post URL when you leave it empty.
Squirrly SEO title, robots, description, keywords and canonical tags in the page source
The canonical link in the page source of a demo post, line 7 (formatted for reading).

Change the canonical with the sq_canonical filter

Add the code to your child theme’s functions.php or a code snippets plugin. Change 123 to your post ID and the address to the original.

add_filter( 'sq_canonical', 'my_squirrly_canonical', 11 );
function my_squirrly_canonical( $canonical ) {
    if ( get_queried_object_id() === 123 ) {
        return esc_url( 'https://www.linkedin.com/pulse/your-article/' );
    }
    return $canonical;
}

At priority 11 the filter gets the URL only. Squirrly builds the <link> tag at priority 99. Return $canonical for the other pages, or they lose their canonical link.

Frequently asked questions

Why don’t I see the Canonical link field?

It only shows in SEO Expert mode, with Add Canonical Meta Link on.

Should I set the canonical to the page’s own URL?

No, leave the field empty and Squirrly writes the page’s own URL.

Does a custom canonical also redirect visitors?

No, for that use the 301 Redirect field in the Visibility tab of the snippet.

Was This Article Helpful?

Before you leave

Future of AEO GEO and AI Search!

Free Now. Free Forever.

It’s time to stop orbiting SaaS.

Be the Meteor.

10 Elite Tools. 1 Stack.