在 Sitefinity 中,Sitemap 生成错误的 URL

In Sitefinity, Sitemap generates wrong URLs

在我的 sitefinity 应用程序中,当我生成站点地图时,它已成功生成,但站点地图在所有节点的 URL 中显示双语言前缀。

喜欢我站点地图中生成的 url 节点

   <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>

总结评论中讨论的内容:

问题是由 SubFolderUrlLocalizationStrategy 具有以下参数引起的: includeSubfoderPrefixForDefaultLanguage = True

删除参数可以解决问题。

这似乎是该版本 Sitefinity 的 Sitemap 模块中的错误,例如我在 v.10.2 中没有看到它。

保留参数并解决问题的一种方法是订阅 ISitemapGeneratorBeforeWriting 事件并在保存之前修改站点地图条目,例如替换("/en/en/", "/en/")

本文展示了如何: 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
}