在我的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>
答案 0 :(得分:1)
总结评论中讨论的内容:
此问题是由 SubFolderUrlLocalizationStrategy 具有以下参数引起的: includeSubfoderPrefixForDefaultLanguage =真
删除参数可解决此问题。
在该版本的Sitefinity中,这似乎是Sitemap模块中的错误,例如在v.10.2中我还没有看到它。
保留参数并解决问题的一种方法是订阅 ISitemapGeneratorBeforeWriting 事件,并在保存之前修改站点地图条目,例如Replace(“ / en / en /”,“ / en /”)
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
}