HTML Link Relationships: Canonical, Alternate and Icon
Identify a preferred URL
A canonical link identifies a preferred version among duplicate or very similar URLs. Search engines may consider it alongside other signals; it is not a redirect or a guarantee of indexing.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Metadata practice</title> <link rel="canonical" href="https://example.com/guides/html"> </head> <body> <h1>HTML guide</h1> </body></html>The preferred absolute URL is available in head.
Describe alternative languages
An alternate link with hreflang identifies a language version of the resource. For multilingual search annotations, use appropriate language tags and reciprocal links across versions. This does not translate the page.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Metadata practice</title> <link rel="alternate" hreflang="en" href="https://example.com/en/guide"> <link rel="alternate" hreflang="fa" href="https://example.com/fa/guide"> </head> <body> <h1>Guide</h1> </body></html>The two alternate links identify English and Persian versions.
Declare an icon
An icon relationship offers an image for browser UI, such as a tab. The type attribute can hint at the resource format. This illustrative path needs an actual asset in deployment.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Metadata practice</title> <link rel="icon" href="/icon.svg" type="image/svg+xml"> </head> <body> <h1>Library guide</h1> </body></html>The icon link is present; the external file and browser UI are not tested.
Common mistakes and practice
Do not confuse rel on link with visible a text. Use one consistent canonical preference and avoid treating alternate language links as canonical replacements.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Link Relationships: Canonical, Alternate and Icon — Knowledge Check
Apply the metadata concepts taught in this lesson.
Which relation expresses a preferred duplicate URL?
Does canonical redirect visitors?
Which attribute describes an alternate language?
Which relation identifies a browser icon?
Does a canonical annotation guarantee indexing?