0

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>
Sami Hussain
  • 179
  • 3
  • 9
  • Can you go to Administration > Settings > Advanced > System > Site Url Settings and see if there is anything there? – Veselin Vasilev Apr 10 '19 at 23:50
  • Where I found URLRulesClient and URLRulesServer with following rules URLRulesClient RegularExpressionFilter -->[^\p{L}\-\!\$\(\)\=\@\d_\'\.]+|\.+$ Replace with --> - ToLower --> checked Trim --> checked URLRulesServer RegularExpressionFilter -->[^\w\-\!\$\'\(\)\=\@\d_]+ Replace with --> - ToLower --> checked Trim --> unchecked – Sami Hussain Apr 11 '19 at 06:59
  • So nothing in the parent level, i.e. Site Url Settings? – Veselin Vasilev Apr 11 '19 at 09:33
  • @VeselinVasilev on parent level of "Site URL Settings" all fields are empty or unchecked – Sami Hussain Apr 11 '19 at 09:55
  • Very strange, do you have any custom URL strategies? This is under Administration > Settings > Advanced > Resources > UrlLocalizationStrategies – Veselin Vasilev Apr 11 '19 at 13:12
  • Yes! Under "SubFolderUrlLocalizationStrategy" I have added a parameter **Key** --> "includeSubfoderPrefixForDefaultLanguage" and **Value** --> "True". – Sami Hussain Apr 11 '19 at 13:28
  • That would explain it if there is a bug in the sitemap module. Try removing the parameter temporarily, restart the site and regenerate the sitemap to see if it fixes it. – Veselin Vasilev Apr 11 '19 at 14:08
  • Making this "includeSubfoderPrefixForDefaultLanguage" Value --> "False", generates fine URLs in sitemap . But I need to keep this value "True" . Is that any other solution? – Sami Hussain Apr 11 '19 at 14:55

1 Answers1

1

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
}
Veselin Vasilev
  • 3,698
  • 1
  • 15
  • 21