{{canonicalLink}} helper

Generates link element with URL to the canonical version of the specific page.

Syntax:

{{canonicalLink}}

This helper has no additional params.

Example output:

<link rel="canonical" href="https://example.com/page-slug/">

The {{canonicalLink}} helper should be used in the <head> section of the website.

Canonical links are used to recognise the base URL for a group of pages with the same content, but available under different URLs. It is a simple way to avoid duplicate content which can affect your website SEO. You can also set a custom canonical URL under post settings.

This helper do the following operations:

If the subpage is set to be not indexed - it returns empty value as canonical URLs are unnecessary when the page is set to noindex.

For other cases it returns the current URL or URL overrided under post settings.

Create your first website with Publii

Join thousands of creators who chose independence. Create content locally and publish lightning-fast, secure websites on your own terms.

Download Publii

Free and open source. Windows, macOS and Linux.

Read the getting started guide