How to exclude URL from sitemap.xml

Al Burns asked on May 21, 2020 09:56

Hi. Can anyone advise how to exclude a URL from sitemap.xml in Kentico 12 MVC SP2? I believe this was possible in Kentico 11 using the web part but I can't see anything in Settings to allow this functionality for v12 MVC. Thanks.

Correct Answer

Juraj Ondrus answered on May 21, 2020 12:24

As mentioned by Dmitry, in Kentico 11 you were using portal engine features. And in MVC, the Google SiteMap is not available since you need to generate the sitemap on your MVC application side. For example I have found these on the Internet: https://stackoverflow.com/questions/884660/how-to-create-google-sitemap-for-mvc-site
http://joelabrahamsson.com/xml-sitemap-with-aspnet-mvc/

0 votesVote for this answer Unmark Correct answer

Recent Answers


Dmitry Bastron answered on May 21, 2020 10:24

Hi,

There is no such a field anymore. We ended up implementing a custom logic for it, luckily it is quite simple to do:

  • created base page type with "Include in sitemap" and "sitemap priority" fields
  • inherited all our page types from the base one to make sure all our pages have these fields
  • during the generation of sitemap we checked those fields and excluded unnecessary pages
0 votesVote for this answer Mark as a Correct answer

Al Burns answered on May 21, 2020 11:28

Thanks for the response Dmitry.

I assume that this is just for generating a normal sitemap page on the site? My issue is with the googlesitemap.xml file that Kentico automatically generates. Is this generated from the sitemap MVC page?

The other thing I wanted to ask in relation to the googlesitemap.xml file is that the date tag is formatted as follows:

However, I have been advised that Google search console is throwing an error because the date is not in the W3C required format of: 2020-04-06T16:07:53+00:00 so the +00:00 is missing. Do you know how this can be added?

Thanks.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on May 21, 2020 11:47

Yes, I was meaning Goggle sitemap.xml, sorry for the confusion. On Kentico MVC I'm not aware of any out-of-the-box functionality to generate Sitemap XML automatically. I can see, that this SEO URL settings support article contains the mention of Google Sitemap, but there is also a small note:

This page must contain the Google Sitemap (XML Sitemap) web part. If left empty, a full sitemap of the website is automatically generated by the ~/CMSPages/GoogleSiteMap.aspx system page.

As far as I know these things (web parts and /CMSPages) exist only on Portal Engine. So my best guess (I'm not 100% certain) would be it's just an error in the documentation and these setting should have been removed from MVC article and left for Portal Engine only. The fact these sitemap settings don't exist (they are just hidden, but still there in the database) in Kentico CMS admin for MVC page types is another proof of it. Therefore Google Sitemap on MVC should be implemented as a custom build. You can confirm this with Kentico support I think to be 100% sure.

0 votesVote for this answer Mark as a Correct answer

Al Burns answered on May 21, 2020 13:02

Great, thanks both.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.