草庐IT

xml - 用于多语言页面的 sitemap.xml

coder 2024-02-29 原文

我用两种语言运行一个多语言网页。我想知道如何准备对 Google 搜索引擎友好的 sitemap.xml 文件。

对于主站点地址example.com,默认语言是pl-PL。简单的语言代码是pl。第二种语言是en-GB,带有简单代码en

所以默认语言的第一个地址是:example.com

第一个lang代码:example.com/pl/(带简单语言代码的域名)是同一个页面。

同样的页面也适用于 example.com/pl/home-page/ (language-code/site-code)

所以使用默认语言的主页有 3 个副本。

第二种语言是en,地址为example.com/en/example.com/en/home-page/

遵循 Google 针对多语言网站的建议:

If two sides do not point to each other, the tags will be ignored. Thanks to this, no one can create a tag on another site pointing to any page as an alternative version of one of your pages.

sitemap.xml 应该是这样的

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
    http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
    http://www.w3.org/1999/xhtml
    http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd">
<url>
    <loc>https://example.com/</loc>
    <xhtml:link rel="alternate" hreflang="pl-PL" href="https://example.com/" />
    <xhtml:link rel="alternate" hreflang="pl-PL" href="https://example.com/pl/" />
    <xhtml:link rel="alternate" hreflang="pl-PL" href="https://example.com/pl/home-page/" />
    <xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en/" />
    <xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en/home-page/" />
    <priority>1.00</priority>
</url>
<url>
    <loc>https://example.com/en/</loc>
    <xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en/" />
    <xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en/home-page/" />
    <xhtml:link rel="alternate" hreflang="pl-PL" href="https://example.com/" />
    <xhtml:link rel="alternate" hreflang="pl-PL" href="https://example.com/pl/" />
    <xhtml:link rel="alternate" hreflang="pl-PL" href="https://example.com/pl/home-page/" />
    <priority>1.00</priority>
</url>
</urlset>

Google Search Console 接受此文件,但我想问一下是否有冗余? 我的简单版本可能是:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
    http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
    http://www.w3.org/1999/xhtml
    http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd">
<url>
    <loc>https://example.com/</loc>
    <xhtml:link rel="alternate" hreflang="pl-PL" href="https://example.com/" />
    <xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en/" />
    <priority>1.00</priority>
</url>
<url>
    <loc>https://example.com/en/</loc>
    <xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en/" />
    <xhtml:link rel="alternate" hreflang="pl-PL" href="https://example.com/" />
    <priority>1.00</priority>
</url>
</urlset>

最佳答案

您应该使用更简单/第二个版本,除非您已经拥有,否则请添加规范标签。每个提交的 URL 都是将特定 URL 包含在 Google 索引中的请求,因此从 SEO 的角度来看,您只需要为每个不同的页面和语言提交一个条目。但是,您必须对重复的页面进行规范化。

关于xml - 用于多语言页面的 sitemap.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55772638/

有关xml - 用于多语言页面的 sitemap.xml的更多相关文章

  1. ruby-on-rails - Rails 常用字符串(用于通知和错误信息等) - 2

    大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje

  2. ruby - 如何将脚本文件的末尾读取为数据文件(Perl 或任何其他语言) - 2

    我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚

  3. ruby-on-rails - 如何从 format.xml 中删除 <hash></hash> - 2

    我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为

  4. Ruby Sinatra 配置用于生产和开发 - 2

    我已经在Sinatra上创建了应用程序,它代表了一个简单的API。我想在生产和开发上进行部署。我想在部署时选择,是开发还是生产,一些方法的逻辑应该改变,这取决于部署类型。是否有任何想法,如何完成以及解决此问题的一些示例。例子:我有代码get'/api/test'doreturn"Itisdev"end但是在部署到生产环境之后我想在运行/api/test之后看到ItisPROD如何实现? 最佳答案 根据SinatraDocumentation:EnvironmentscanbesetthroughtheRACK_ENVenvironm

  5. ruby - 寻找通过阅读代码确定编程语言的ruby gem? - 2

    几个月前,我读了一篇关于ruby​​gem的博客文章,它可以通过阅读代码本身来确定编程语言。对于我的生活,我不记得博客或gem的名称。谷歌搜索“ruby编程语言猜测”及其变体也无济于事。有人碰巧知道相关gem的名称吗? 最佳答案 是这个吗:http://github.com/chrislo/sourceclassifier/tree/master 关于ruby-寻找通过阅读代码确定编程语言的rubygem?,我们在StackOverflow上找到一个类似的问题:

  6. ruby - inverse_of 是否适用于 has_many? - 2

    当我使用has_one时,它​​工作得很好,但在has_many上却不行。在这里您可以看到object_id不同,因为它运行了另一个SQL来再次获取它。ruby-1.9.2-p290:001>e=Employee.create(name:'rafael',active:false)ruby-1.9.2-p290:002>b=Badge.create(number:1,employee:e)ruby-1.9.2-p290:003>a=Address.create(street:"123MarketSt",city:"SanDiego",employee:e)ruby-1.9.2-p290

  7. Unity 热更新技术 | (三) Lua语言基本介绍及下载安装 - 2

    ?博客主页:https://xiaoy.blog.csdn.net?本文由呆呆敲代码的小Y原创,首发于CSDN??学习专栏推荐:Unity系统学习专栏?游戏制作专栏推荐:游戏制作?Unity实战100例专栏推荐:Unity实战100例教程?欢迎点赞?收藏⭐留言?如有错误敬请指正!?未来很长,值得我们全力奔赴更美好的生活✨------------------❤️分割线❤️-------------------------

  8. 7个大一C语言必学的程序 / C语言经典代码大全 - 2

    嗨~大家好,这里是可莉!今天给大家带来的是7个C语言的经典基础代码~那一起往下看下去把【程序一】打印100到200之间的素数#includeintmain(){ inti; for(i=100;i 【程序二】输出乘法口诀表#includeintmain(){inti;for(i=1;i 【程序三】判断1000年---2000年之间的闰年#includeintmain(){intyear;for(year=1000;year 【程序四】给定两个整形变量的值,将两个值的内容进行交换。这里提供两种方法来进行交换,第一种为创建临时变量来进行交换,第二种是不创建临时变量而直接进行交换。1.创建临时变量来

  9. ruby - 在 ASP 页面上 Mechanize 中断 - 2

    require'mechanize'agent=Mechanize.newlogin=agent.get('http://www.schoolnet.ch/DE/HomeDE.htm')agent.clicklogin.link_withtext:/Login/然后我得到Mechanize::UnsupportedSchemeError。 最佳答案 Mechanize不支持javascript但您可以将搜索字段添加到表单并为其分配搜索词并使用mechanize提交表单form=page.forms.firstform.add_fie

  10. ruby - "undefined method"用于 rails 模型 - 2

    我正在使用带有Rails的Devise,我想添加一个方法“getAllComments”,所以我这样写:classUser在我的Controller中:defdashboard@user=current_user@comments=@user.getAllComments();end当我访问我的url时,我得到了undefinedmethod`getAllComments'for#我做错了什么?谢谢 最佳答案 因为getAllComments是一个类方法,而您正试图将其作为实例方法访问。您要么需要访问它:User.getAllCom

随机推荐