November Happy Hour will be moved to Thursday December 5th.

Henrik Buer
May 1, 2011
  17158
(3 votes)

XML Sitemap for EPiServer CMS as a scheduled job, supported by search engines such as Google, Yahoo, Bing etc.

This sitemap generator adheres to the 0.9 version of the sitemap protocol as specified by sitemaps.org

Many of the public sites that I’ve been working with has used sitemaps both as XML sitemaps (sitemaps.org) and as simple text files (one URL/line). In my effort to reduce the repetitive work when developing sites, I decided to write a plug-in that I can just drop in the bin folder and be done with it so I can focus on the fun stuff.

I’ve seen sitemap generators for EPiServer that generates the sitemap on-the-fly when requested. If your site has a lot of pages this is a bad idea since it can be a lengthy process. There is also generally no need for the sitemap to reflect the absolute latest site structure the moment it’s requested because it’s only indicative i.e. the search engines does not guarantee to index every URL in the sitemap but it uses the sitemap to learn about the site structure. The final decision what URLs are indexed is up to the search engines algorithms. As stated in the blog post title this is a scheduled job so you can set the generation intervals to suite your needs.

The code isn't really that exiting. I use FindPagesWithCriteria to get the sites pages. After that I FilterForVisitor and remove the pages that are shortcuts to external pages from the collection to get a final set of pages to generate the sitemap for. Every language that the page exists for generates an URL.

The sitemap protocol specifies optional tags, change frequency and priority. My plug-in has two properties to facilitate this. After installation you may create properties on your page types or dynamic  properties if you want to use these tags. Remember that setting all pages to the highest priority (1.0) won’t improve your ranking nor does setting all pages to the lowest priority (0.0) decrease your ranking  The priority is relative to other pages on your site.

Limitations

A sitemap can contain a maximum of 50 000 URLs and be no larger than 10Mb. This plug-in doesn’t check for or consider those boundaries.

Installation

Drop the Sitemap.dll in your bin folder and the language file (xCreateSitemap.xml) in your lang folder. Configure the path to where the sitemap should be written (se below).

Configuration

Use the Plug-in Manager to set a path to where the sitemap should be written. This should be in your sites structure and preferably in your root so that you can provide a link for search engines i.e http://www.mysite.se/sitemap.xml. You might have to configure access rights to the sitemap.

You can also specify what time format to use for the “lastmod” timestamp. Default is “yyyy-MM-dd”. If your pages change frequently you are encouraged to include the time portion so crawlers have more complete information about your site i.e. “yyyy-MM-ddTHH:mm:sszzz”. The timestamp should be in W3C Datetime encoding

Configure_Sitemap

Configure_Sitemap2

If you want to use priority or change frequency create properties named “Priority” and “ChangeFrequency” on your page types or as dynamic properties. These properties should be of the included types “Priority” and “Change frequency”

Compiled binary (CMS 6 R2, .Net 3.5)

Source code

May 01, 2011

Comments

Jonas Granstrand
Jonas Granstrand May 6, 2011 10:06 AM

Hello

This looks really nice, having one problem though.

i get an error when i try to run the job.

The job failed: Exception has been thrown by the target of an invocation. [Access to the path 'C:\EPiServer\Sites\SandboxSite2' is denied.]

Is this due to the configuration you are talking about and how do i set access rights to be able to write the sitemap?

/Jonas

Henrik Buer
Henrik Buer May 6, 2011 10:22 AM

Hi

In this case I think it's not an access issue. Try specifying the path and file name i.e "C:\EPiServer\Sites\SandboxSite2\Sitemap.xml" and see if that does the trick.

Jonas Granstrand
Jonas Granstrand May 6, 2011 12:16 PM

Doesn't work. A new error message:

The job failed: Exception has been thrown by the target of an invocation. [The given path's format is not supported.


Btw, before i continue down this track: Does this solution work for an enterprise enviroment?

Henrik Buer
Henrik Buer May 6, 2011 12:46 PM

Haven't tested it in an enterprise installation but you can only generate one sitemap. If you would like to have one sitemap/site you'll have to modify the source.

For the exception I guess you'll have to compile a debug version and try to find out what's wrong. Perhaps you can try double slashes "\\" in the path?

Jonas Granstrand
Jonas Granstrand May 6, 2011 01:03 PM

OK, thx

What do you think:

Ex.
If i have an enterprise enviroment with an international site (.com) and 3 different country specific sites of that one (.se,.dk,.fi), do you think i should have one sitemap for each of thoose sites or should all be index in the same sitemap?

Henrik Buer
Henrik Buer May 6, 2011 01:16 PM

You should definitely have one sitemap / site. The sitemap protocol states (http://sitemaps.org/protocol.php#index):

Note: A Sitemap index file can only specify Sitemaps that are found on the same site as the Sitemap index file. For example, http://www.yoursite.com/sitemap_index.xml can include Sitemaps on http://www.yoursite.com but not on http://www.example.com or http://yourhost.yoursite.com.

Jonas Granstrand
Jonas Granstrand May 6, 2011 01:21 PM

Ok, thank you for your help!
i'll compile a debug version and try to solve the issue.

(and i'll also read up on the sitemap specs) =)

For now i will stick to the epiGoogleSitemaps for my enterprise enviroment and try to get your neat solution to work for my single sites.

Thanks again!

Suren Azatyan
Suren Azatyan May 9, 2012 11:03 AM

thanks for module

Dinesh Yadav
Dinesh Yadav Oct 16, 2013 01:14 PM

Hi,

Is there a feature to exclude any page from sitemap.url

Henrik Buer
Henrik Buer Oct 16, 2013 01:37 PM

Nope. No such feature but you can easily modify the source to fit your needs.

Komal Goyani
Komal Goyani Jun 10, 2014 04:09 PM

Hi,
I am new to EpiServer and one SEO guy ask me to create different sitemaps for different languages.
How can i do that?
And where and how can i set set priority and Frequency in above code?

Please login to comment.
Latest blogs
CMS Core 12.22.0 delisted from Nuget feed

We have decided to delist version 12.22.0 of the CMS Core packages from our Nuget feed, following the discovery of a bug that affects rendering of...

Magnus Rahl | Dec 3, 2024

Force Login to Optimizely DXP Environments using an Authorization Filter

When working with sites deployed to the Optimizely DXP, you may want to restrict access to the site in a particular environment to only authenticat...

Chris Sharp | Dec 2, 2024 | Syndicated blog

Video Guides: Image Generation Features in Optimizely

The AI Assistant for Optimizely now integrates seamlessly with Recraft AI, providing advanced image generation capabilities directly within your...

Luc Gosso (MVP) | Dec 1, 2024 | Syndicated blog

DAM integration new major version, performance improvements and Library Picker folder selection

As you might already have seen we have decided to delist the EPiServer.CMS.WelcomeIntegration version 1.4.0 where we introduced Graph support....

Robert Svallin | Nov 29, 2024