outubro 06, 2016
Having multiple URLs to the same page can negatively impact your site's search engine optimization (SEO). When working with Sitecore this is very important to understand since Sitecore has the capacity to output a number of different URL formats.
For example, looking at your home page, all of the following URLs are valid and will resolve your home page:
http://<<mywebsite>>.com
http://<<mywebsite>>.com/?sc_lang=en
http://<<mywebsite>>.com/en
http://<<mywebsite>>.com/home.aspx
http://<<mywebsite>>.com/home
http://<<mywebsite>>.com/en/home
http://<<mywebsite>>.com/sitecore/content/home.aspx
http://<<mywebsite>>.com/sitecore/content/home
http://<<mywebsite>>.com/en/sitecore/content/home
http://<<mywebsite>>.com/?sc_itemid=%7B110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9%7D
But, didn't you just say this was bad? Well, yes, but just because they are all valid doesn't mean that Sitecore expresses all of those URL formats for consumption by search engines or site visitors. With proper configuration you can suppress the variations in favour of your preferred URL format.
Two key Sitecore configuration areas contribute to the URL format:
- the Link Manager
- the Site Definition
Link Manager
Sitecore's Link Manager is responsible for the generation of page URLs internal to Sitecore. Link Manager has a number of settings that allow you to manipulate your URL pattern.
Here are the most commonly updated attributes:
- The languageEmbedding setting allows you to determine if the URL of the page contains the language code (i.e. en-CA, fr-CA, etc.)
- The languageLocation setting determines the location the language code is embedded in the URL. Either immediately following the hostname or as a query string parameter (?sc_lang=en-FR).
- The addAspxExtension adds .aspx to the end of your URL
It is extremely important for developers to leverage the Link Manager when functionality necessitates outputting a URL via code. If the Link Manager is not used in favour of custom generated code, it is highly likely that your site would generate multiple different URLs to the same page.
When improperly configured, you may see URLs similar to these examples:
http://<<mywebsite>>.com/?sc_lang=en
http://<<mywebsite>>.com/en
http://<<mywebsite>>.com/home.aspx
http://<<mywebsite>>.com/home
http://<<mywebsite>>.com/en/home
Site Definition
The site definition allows Sitecore to identify which site is being loaded (in the case of a multisite implementation), and which item in the content tree corresponds with that site.
Here are the most commonly updated attributes:
- The hostName is the value of the incoming url
- I wrote a blog post previously that dug into how the hostName attribute contributes to your URL format over here. You can read the post if you want to get into the different nuances, but the overall observation is that the hostName attribute can influence the path structure of your URLs, especially in a scenario where you are hosting more than one site in the same Sitecore instance.
- The startItem is the internal Sitecore path to the start item of your site (e.g. "/home")
- The rootPath attribute points to the root item of the site (e.g. "/sitecore/content")
When improperly configured, you may see URLs similar to these examples:
http://<<mywebsite>>.com/sitecore/content/home.aspx
http://<<mywebsite>>.com/sitecore/content/home
http://<<mywebsite>>.com/en/sitecore/content/home
Conclusion
Even after you've tuned your configurations to express your preferred URL format, those additional URLs remain valid and will resolve if they are input manually or through improper programming.