Sitemap and Robots Generator for Optimizely/Episerver CMS 12

Sitemap and Robots Generator for Optimizely/Episerver CMS 12

This blog post is a continuation to the blog post about the Sitemap and Robots Generator for Episerver CMS, where you can find how to install and configure the plugin, the blog post about the Sitemap and Robots Generator for Commerce Episerver CMS, which explain how to add products to the sitemap file and the blog post about the Sitemap and Robots Generator Filter Programmatically by Type, which explains how you can programmatically filter your sitemap items by type. In here, we are going to explain how we can configure plugin for the new version of the Optimizely/Episerver CMS 12 which uses core instead of MVC. For this, we will use the latest version available of the plugin which at the time of writing is From now on, the plugin will use the dot net mayor version as the first identifier in the plugin package version. In this case, 5 is for dot net core 5.0 which is required for CMS 12. You can find the plugin developed by Verndale in this link. If you cannot find the latest version in the episerver feed please use the nuget feed instead.

To begin, we are going to install the package using the Package Management Console and this command

Install-Package Verndale.Sitemap.Robots.Generator -Version

Please read carefully the Readme file. Some of the new changes we brought to this version are mentioned in there, but most important, it explains how to configure several parameters of the plugin which we will also explain meticulously later in this post.

After installation, we will copy the following lines to your base page, this is not required, but it is needed if you want more control over the pages that are going to appear in the sitemap, its frequency and priority. Please pay special attention to the comments in the code.

[Display(GroupName = "Navigation",
        Name = "Exclude from Xml Site Map",
        Order = 400)]
public virtual bool ExcludeFromSiteMap { get; set; } // Exclude this page from the sitemap
[Display(GroupName = "Navigation",
    Name = "Priority in Site Map",
    Order = 500)]
public virtual string Priority { get; set; } // The priority applied to this page in the sitemap
[Display(GroupName = "Navigation",
    Name = "Change Frequency of Page in Site Map",
    Order = 600)]
public virtual string ChangeFrequency { get; set; } // The frequency applied to this page in the sitemap

Because, core does not use handlers anymore you must now add in your startup class or where you initialize your site features. For instance, in the configure method of the startup class.

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    app.UseSitemapRobotsMiddleware(); // Line to add

Next, we need to add the application settings for the plugin in the appsettings.json file. In the previous version we were able to add this automatically using web config transforms but this is not a feature anymore for dot net core nuget packages.

  "Siro": {
    "Show_Localized_URLS": "true",
    "Display_Localized_URLS_Separated": "false",
    "Show_Trailing_Slash": "false",
    "SiteMap_OutPutRobots_txt": "1"

With these changes in your code and configuration files, it is enough to make the plugin work as expected. Now we are going to explain the application settings configurations which you can modify to fit your needs inside the appsettings.json file.

Show_Localized_URLS (true/false)If the sitemap is going to show localized urls based on google recommendations with href lang attribute
Display_Localized_URLS_Separated (true/false)If the sitemap is going to display the localized urls separated instead of using href lang
Show_Trailing_Slash (true/false)Show a trailing slash at the end of each URL in the sitemap
SiteMap_OutPutRobots_txt (1/0)If the Sitemap URL is going to be added to the robots content after the sitemap is generated

The previous version of the plugin for CMS 11 had a sitemap.config file inside the App_Config folder, but we are not using it anymore because it was only used for XML name spaces configurations and those did not change enough to justify the separated file. Finally, this version now properly support middleware for IIS express and Kestrel servers so you can see your sitemap and robots files in those servers.

Finally, to access the configuration section of the plugin, you now have to go to the admin section, and then to the Sitemap & Robots tab next to the tools tab.

And that is it. You can now use the Sitemap and Robots plugin in the new Optimizely/Episerver CMS 12 version without any issues. If you have any questions or suggestions please let me know in the comments. I hope this plugin can help someone and as always keep learning !!!

(Update) From version the issue with duplicated hostnames in the sitemap.xml file should be fixed.

Written by:

Jorge Cardenas

Developer with several years of experience who is passionate about technology and how to solve problems through it.

View All Posts


comments user
Luc Gosso

Hi Jorge! Great plugin, does it exists on github? I would like to use it, but not without the source code.

This is how my loc looks like, cant figure why… ? https://localhost:8000/https://localhost:8000/blog/november/

Seems like the keys SiteMap_OutPutRobots_txt and Show_Trailing_Slash does not do any difference, are they?

PS the google login does not work for comments

    comments user
    Jorge Cardenas

    Greetings Luc. Sorry for such a late response. Yes the plugin had an issue due to the new resolver in the Optimizely Episerver CMS 12, the newer versions fix the issue. If you have any other error please let me know.

comments user

Hi Jorge,

thanks for this package, looks great!
However, when generating the sitemap, the URLs generated contain the hostname twice;

Any idea how to fix this?

    comments user
    Jorge Cardenas

    Thanks for the feedback and help us fix this issue. Latest version should work without issues.

comments user
Sumit Bhatia

Hi Jorge, After installing the package, when I run sitemap.xml, It doesn’t show anything on the page. Also in the Admin, when I click on the Update restricted types button, it redirects me to this URL “https://localhost:44335/sitemapplugin/updaterestrictedtypesandsites”

and the page shows “This page isn’t working”.

Can you let me know what I am missing?

    comments user
    Jorge Cardenas

    Hi Sumit Bhatia. Would you mind telling me which CMS 12 version are you using to check if we have an issue in there?

Leave a Reply