sitefinitysitefinity-8

In Sitefinity, Sitemap generates wrong URLs


In my sitefinity application, when I generates sitemap it gets successfully generated but site map shows dual language prefix in URLs for all nodes.

Like a generated url node in my sitemap

   <url>    
    <loc>http://www.example.net/en/en/individual/customer- 
    service</loc>
    <priority>1</priority>
    <xhtml:link rel="alternate" hreflang="en" 
    ref="http://www.example.net/en/en/individual/customer-service" />
     <xhtml:link rel="alternate" hreflang="ar"
     ref="http://www.example.net/en/ar/individual/customer-service" />
     </url>

But I expect the generated url node like this

   <url>    
    <loc>http://www.example.net/en/individual/customer- 
    service</loc>
    <priority>1</priority>
    <xhtml:link rel="alternate" hreflang="en" 
    ref="http://www.example.net/en/individual/customer-service" />
     <xhtml:link rel="alternate" hreflang="ar"
     ref="http://www.example.net/ar/individual/customer-service" />
   </url>

Solution

  • To summarize what was discussed in the comments:

    The issue is caused by the fact that the SubFolderUrlLocalizationStrategy had the following parameter: includeSubfoderPrefixForDefaultLanguage = True

    Removing the parameter resolves the issue.

    This seems to be a bug in the Sitemap module in that version of Sitefinity, as I haven't seen it in v.10.2 for instance.

    One way to keep the parameter and overcome the issue is to subscribe to the ISitemapGeneratorBeforeWriting event and modify the sitemap entries before they are saved, e.g. Replace("/en/en/", "/en/")

    This article shows how: https://knowledgebase.progress.com/articles/Article/How-to-modify-the-entries-in-sitefinity-sitemap-using-SitemapGeneratorBeforeWriting-event

    protected void Application_Start(object sender, EventArgs e)
    {
        Bootstrapper.Initialized += Bootstrapper_Initialized;
    }
    
    void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
    {
        if (e.CommandName == "Bootstrapped")
        {
            EventHub.Subscribe<ISitemapGeneratorBeforeWriting>(evt => SitemapGeneratorBeforeWritingHandler(evt));
        }
    }
    
    void SitemapGeneratorBeforeWritingHandler(ISitemapGeneratorBeforeWriting @event)
    {
        var entries = @event.Entries;
        // CRUD operations over the sitemap entries goes here
    }