Views: 11708
Number of votes: 3
Average rating:

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

Jonas Granstrand
(By Jonas Granstrand, 5/6/2011 12:06:39 PM)

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
(By Henrik Buer, 5/6/2011 12:22:49 PM)

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
(By Jonas Granstrand, 5/6/2011 2:16:30 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
(By Henrik Buer, 5/6/2011 2:46:15 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
(By Jonas Granstrand, 5/6/2011 3:03:09 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
(By Henrik Buer, 5/6/2011 3:16:26 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
(By Jonas Granstrand, 5/6/2011 3:21:47 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
(By Suren Azatyan, 5/9/2012 1:03:03 PM)

thanks for module

Dinesh Yadav
(By Dinesh Yadav, 10/16/2013 3:14:56 PM)

Hi,

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

Henrik Buer
(By Henrik Buer, 10/16/2013 3:37:57 PM)

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

Komal Goyani
(By Komal Goyani, 6/10/2014 6:09:49 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.