Subscribe to our blog!

Subscribe
sitemap

Add custom formatted URLs to Sitefinity sitemap

  • Webmaster Tools
  • Google
  • Sitefinity
  • SEO
  • sitemap
By on

When building dynamic URLs in Sitefinity, we, developers often tend to forget how important implementing a logic to dynamically add new custom URLs in the holy book of SEO – the Sitemap. Luckily, Sitefinity has a built-in Sitemap Generator which can be easily tuned to include our custom URLs programmatically.

The basics

Crawling and Crawlers

 

               Crawling is the process of acquisition of data about a website. In order to display the most relevant information to their clients, the search engine must first collect and “know” that information. This is exactly what crawling is in general - the process of acquisition of data about a website.

To perform Crawling, search engines use Crawlers – automated programs with incredibly complex algorithms, which scan the webpages to see what words they contain and where those words are used. The Crawler than turn those words to Index – a database of “knowledge”, which is used to provide the best information to the Search engine users.

What is a sitemap?

 

In general, sitemap is a list of all the website pages. Its purpose is to provide information for the Crawlers about all the pages of the website – their URLs, their priority, their last modification date and how often they get edited. This eases the job of the crawlers. An optimized sitemap is crucial for the SEO rating, and missing one will lead to SEO penalties.
Considering how important SEO is in the today's business world, having a good and descriptive sitemap is A MUST.

Dont let crawlers get lost!             

   

A healthy sitemap should consist of all the pages that are on the website. This is especially important when the site is large and has a lot of dynamically generated pages. But when using Sitefinity CMS to custom generate URLs, listing all of them in the sitemap is easier said than done.

Below is an example of a single URL of a sitemap can consist of. Note that only the <loc></loc> field is required, the others are optional.

<url>
<loc>http://www.example.com/</loc>
<lastmod>2016-04-02</lastmod> 
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>

 
Additional info about sitemaps can be found on: https://www.sitemaps.org/


Sitemaps and Sitefinity

 

Sitefinity has built-in Sitemap Generator, which does most of the job itself. It can be accessed in the backend, under Administration tab. From there, settings about how often the sitemap should be generated, at what exact time, etc. can be edited.

Another interesting functionality in Sitefinity sitemap generator is, that each time sitemap is generated, Sitefinity automatically pings Google and Bing search engines.
More about sitemap generator can be found in Sitefinity official documentation.

Defining the problem

By default Sitefinity appends the publication date, next to the content item URL. You can easily tweak Sitefinity to remove the date (see blog post here). However, this will not be enough for the Sitefinity Sitemap Generator module to use the new custom URL format.

Solution

    One of the simplest, yet right on point approaches, is to simply build additional entries, consisting of all required items – URL, priority, etc. (this might require building the full URLs as strings). Then add these new entries to the entries that are to be written by Sitefinity Sitemap Generator, using the out-of-the-box event, which fires right before sitemap is being written.

Solution plan:

  1. Subscribe to Before_Writing event, which fires every time sitemap is generating.
  2. Get all the entries that are about to be written on the sitemap.
  3. Create new sitemap entry for each custom URL, add the URL to entry.Location, and set the other desired XML tags.

Example:

Let’s say we are using a custom blogs widget with custom formatted URLs. Ideally we would like to achieve the following as a result in our sitemap:

Follow the steps below to achieve the required result:

1. Open the Global.asax and on Application_Start, attach an EventHandler method to the SystemManager.ApplicationStart event: 



2. Subscribe to Before_Writing event:

3. Add the custom entries (find additional explanation in the code snippet comments).

4. Finally, you need to re-generate the sitemap via Sitefinity's Sitemap Generator.

In order to generate a sitemap, access the Sitefinity backend >> Administration >> Sitemap >> Generate Now. After the generation is completed, the sitemap can be accessed directly in the browser by navigating to:

~/sitemap/sitemap.xml

----

Argo's advice: Do not forget to point the location of your sitemap in the robots.txt file.

Back To List

By continuing to use this website you are agreeing to its use of cookies. To find out more, please see our cookie policy.