When implementing link tags, first identify their purpose: loading resources, specifying a canonical URL, or identifying alternate versions. Then check that the attribute combinations and placement are correct and that the URL settings are consistent. In particular, do not combine canonical annotations with language or device-version annotations in the same tag, or let HTML, HTTP headers, and JavaScript specify different canonical URLs. The following covers the uses of link tags and key points for implementing canonical tags. Keep in mind that restrictions for one use do not necessarily apply to all link tags.
Confirm the purpose first—do not stop at entering a URL
rel indicates the relationship between the current document and the linked resource, while href provides the resource URL. Loading stylesheets, preloading resources, and specifying canonical URLs are different tasks. Even though all use link tags, you should not copy an entire set of attributes without checking what the tag is meant to do.
A Semrush article dated 2021 notes that each attribute has allowed values and may need to be paired with other attributes. Its explanation of preload offers an example:
- When using rel=”preload”, you must include as to indicate the resource’s type or purpose.
- For example, when preloading a stylesheet, as should be set to style rather than an arbitrary resource type.
In general, href can specify relative or absolute URLs. However, Google has separate recommendations for canonical URLs, so relative paths should not be used indiscriminately.
Place canonical tags correctly and specify the URL explicitly
According to Google’s documentation, Google accepts an HTML canonical element only when it appears in a valid head section. Checking for a canonical tag is therefore not enough; you also need to confirm where it appears. This placement requirement applies to canonical tags, not necessarily to all link tags.
For canonical tags, use an absolute URL that includes the protocol and domain, rather than just a path. Although Google supports relative paths, it warns that they may cause problems over time, such as unintentionally allowing a test site to be crawled.
If multiple URLs serve the same content, the canonical tags on duplicate pages should point to the selected canonical page. Google also recommends adding a self-referencing canonical tag to the canonical page. Do not interpret “self-referencing” to mean that every duplicate page should point to itself.
Avoid conflicting settings and keep alternate-version annotations separate
Google supports specifying canonical URLs through HTML elements or HTTP headers, but recommends choosing one method. The two can coexist, but using both makes it easier to mistakenly specify one URL in one place and a different URL in the other.
- For client-side rendered sites, it is best to specify the canonical URL in the original HTML and avoid changing it with JavaScript. Rely on JavaScript alone only if you cannot set the canonical URL in the original HTML.
- Do not add hreflang, lang, media, or type to canonical annotations. According to Google’s documentation, canonical annotations with these attributes are not used to determine the canonical URL.
- Use separate, appropriate alternate and hreflang annotations for language and country/region versions. If the canonical page has a mobile version at a separate URL, also add a separate alternate annotation pointing to that mobile version.
The key is to clearly distinguish “which URL is canonical” from “which alternate versions exist,” rather than putting all the information into a single tag.
Implementing link tags: perspectives from across the web
Should hreflang annotations include the current page?
In a 2017 article, Semrush recommends including the current page's URL and language code in a set of hreflang annotations. Missing self-references may cause the annotations to be ignored or misinterpreted. When checking them, confirm that every language or regional version is listed with the correct corresponding information, rather than listing only the other versions.
What timing risks does hreflang pose for news sites?
The risk is that reciprocal hreflang annotations may not appear in Google's index in time. If regional versions of a news story are published at different times, a later version may already point to the original before Google recrawls it. The indexed version of the original would therefore still lack the corresponding return annotation. A Search Engine Journal author notes that recrawling the original may take several hours and therefore considers hreflang unsuitable for news publishing that aims to capture immediate traffic. This assessment applies to that publishing scenario; it does not mean that all websites should avoid hreflang.
Which link attributes should you check in legacy code?
Check whether obsolete attributes such as rev, charset, methods, or target are still in use, then replace them as appropriate for their purpose. Such attributes may stop working as browsers phase out support. Semrush notes, for example, that rev originally expressed a reverse relationship and that the W3C recommends using the more flexible rel instead. When replacing it, however, you still need to confirm that the intended relationship is expressed correctly.
What should you consider when loading cross-origin resources and setting resource priorities?
When loading cross-origin resources, confirm that the crossorigin setting matches the required handling of credentials. For example, anonymous means fetching the resource anonymously, without sending credentials such as cookies. fetchpriority helps the browser prioritize resource fetching. Handling it correctly may improve performance, but the benefit should not be treated as guaranteed.
References
- 如何使用 rel="canonical" 和其他方法指定標準網址 | Google 搜尋中心 | Documentation | Google for Developersdevelopers.google.com — Source used in the article above.
- HTML Link Tags Explained (+ All Attributes and Values)www.semrush.com · 2021-05-20T04:08:00Z — Discusses: Which link attributes should you check in legacy code?; What should you consider when loading cross-origin resources and setting resource priorities?
- International SEO For Publishers: How To Succeed Across Borderswww.searchenginejournal.com · 2026-09-21T19:00:39+00:00 — Discusses: What timing risks does hreflang pose for news sites?
- 13 Most Common Hreflang Mistakes [Semrush Study]www.semrush.com · 2017-02-15T03:00:00Z — Discusses: Should hreflang annotations include the current page?

