The purpose of a canonical header tag is to tell search engines that a given URL is the authoritative source for a piece of content, eliminating the damage to SEO rankings if there are multiple versions of the same piece of content. StackPath now provides a canonical header switch that, when enabled, sets a canonical header for the different CDN assets served.
Search engine optimization is of pinnacle importance to many users of StackPath, and canonical tags are considered a must-have for search engine crawlers. To search engines, example.com, www.example.com, and https://www.example.com/ are all different pages with identical content. Without a canonical header tag, search engines will use their best guess at which content is considered primary, however, SEO can also be negatively impacted due to duplicate content. Adding a canonical header tag allows the user to specify the primary page, removing the guesswork and reducing the chance a search engine views a given page as duplicate, or 'plagiarized'.
Using the Canonical Header
The global canonical header rule will set a specified canonical header on each page so that variations of the content all point back to the originator.
The rule inserts <link rel="canonical" href="{hostname}/URI"> on each page to establish which URL is the originator.
Verifying the Rule
This rule adds a public response header to the CDN Response. Verify it by checking the headers from CDN assets using browser inspect tools or cURL requests.
For browser tools, right-click anywhere on the website and select Inspect or Inspect Element and navigate to the Network tab. If the page isn't populated with requests, refresh the page with this tab open to view them as they come in.
Any assets served through the CDN may be selected to view the request headers and verify that the rel ="canonical"
appears in the header list, similar to the example below.
If any questions arise or assistance is needed, feel free to drop us a line at hi@stackpath.com