Canonical page: rel=canonical

Contents
The canonical tag
Rules
Canonical in an HTTP header
Canonical or redirect
Check a page

One page is often reachable under several URLs: with and without www, with tracking parameters such as UTM tags, as a print version. For a search engine these are different pages with the same text. The canonical URL tells it which one is the main page, so that the copies do not compete with it in the results.

The canonical tag

Put a link element into the head of every copy, pointing to the main URL:

<head> … <link rel="canonical" href="https://www.example.com/docs/install/"> … </head>

Rules

Canonical in an HTTP header

A PDF or another file without a head gets its canonical as an HTTP header:

Link: <https://www.example.com/docs/install/>; rel="canonical"

On Apache the header can be set in .htaccess, see .htaccess.

Canonical or redirect

When the old URL should no longer be shown at all, for example after a move, use a 301 redirect instead: the visitor and the search engine both land on the new page. Canonical is for copies that must stay reachable. Redirects are explained in Redirects.

Check a page

Look for the tag in the HTML with curl:

curl -s https://www.example.com/docs/install/ | grep -i canonical

For the header variant, ask for the headers only:

curl -sI https://www.example.com/docs/file.pdf | grep -i '^link:'

Article authors: Andrei Olegovich, Klavdiya Kondakova

Related articles
Responsive design: an adaptive menu
Beget mail: create a mailbox
Canonical page: rel=canonical
CSS
Firefox
Which hosting to choose
VPS hosting
HTTP status codes
Joomla
OpenCart
PUT vs POST
Redirects
Russian IP ranges
SEO
Element tbody not allowed as child of element table in this context
CSS test: shapes and line numbers
CSS test 2: the code blocks of this site
Website testing
A tram drawn with CSS
URL encoding
UTM tags
Telling bots from people
WebP images
Moving a website: domain and hosting
WordPress
Move a WordPress site
Yandex Metrica: goals
Yandex Mail: collect mail from other mailboxes
Banner image

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: