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'.
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. To change the setting for this rule:
- Login at control.stackpath.com.
- Navigate to Sites > domain > CDN
- Change the switch for Canonical Header to the desired setting, and list the desired hostname in the Hostname box.
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.
When performing a cURL test, the option -I is important to include in order to see the headers appropriately. Below is an example of a curl, with the rel="canonical" header highlighted.
If any questions arise or assistance is needed, feel free to drop us a line at email@example.com or come into our 24/7 support chat!