SEO Tips – How to Generate Sitemap.xml On The Fly In Umbraco 7.4.0?

SEO Tips

How to Generate Sitemap.xml On The Fly In Umbraco 7.4.0?

In simple terms, a Sitemap is an XML file that is full of your individual webpage’s URLs. It’s like an archive of every webpage in your website. This file should be easily discoverable in your site in order for search engine crawlers to stumble upon it.

Simple Sitemap.xml Umbraco Handler

Umbraco is a fully-featured open source content management system with the flexibility to run anything from small campaign or brochure sites right through to complex applications for Fortune 500’s and some of the largest media sites in the world.

Sitemap.xml is important component of SEO which is responsible for indexing your website. Search engine robots are generating indexes of your website based on this file.

Since content in Umbraco website is dynamic, it makes not so much sence to have static sitemap.xml file for indexing your content. Instead it is a lot better to have this XML structure generated on the fly based on the content and structure.

The logic for generating sitemap.xml should be to include only those pages which are visible to the visitor, which means excluding pages which dot not have templates defined (data nodes in Umbraco for storing the data) and pages which are marked as invisible based on some property (usually boo property umbVisible)

This means the code which generates the output XML needs to take this in consideration when generating the XML.

Regarding the structure, it should follow recommendation from search engines such as Google as dominant search engine these days, but it also needs to simply with others like Bing and Yahoo. Recommendations about the stricture of sitemap.xml can be found in help documentation of these search engines.

Since this output does not need to be managed direly from the back-end as it automatically generates the output, I decided to implement it as HttpHandler. To make it work it need to be defined in web.config file.

Rapidly build your website using Umbraco with powerful API’s and easy extensibility. The Umbraco API gives you programmatic access to everything in the Umbraco CMS, plus the API is easy to use from Visual Studio or any other development tool.

The following code can be used out of the box and it mainly implements Google search engine recommended structure for sitemap.xml.

Since the code runs through the whole site structure it makes sense to cache the output to reduce site load generated by search engine crawlers. Depending on the content update frequency, you should set expiration period.

SEO Tips – How to Generate Sitemap.xml On The Fly In Umbraco 7.4.0?
3 (60%) 1 vote