gpt4 book ai didi

html - 链接到 HTML 纯文本站点地图文件的正确方法是什么?

转载 作者:行者123 更新时间:2023-12-04 16:32:50 25 4
gpt4 key购买 nike

此代码是否会正确指示 Google 为我的站点地图编制索引(或使其知道它存在)?

<link rel="sitemap" href="./sitemap.txt" type="text/plain" title="Sitemap" />
Google 在其 instructions 中声明允许简单地列出 URL 的纯文本文件作为站点地图格式,但我找不到关于如何在 HTML 中链接到此类文件的任何经过验证的解决方案 <head> .
我修改了 this answer 中的解决方案通过更改 type属性。这是链接到纯文本站点地图文件的可接受方式吗?
我意识到我可以直接将文件提交给谷歌,例如。 https://www.google.com/ping?sitemap=FULL_URL_OF_SITEMAP ( Source )
但我想将它包含在标记中,以便其他搜索引擎(以及任何想要它的人)也可以找到它。

最佳答案

回答您的问题:HTML5 定义了您可以在 rel 中使用的值。和 sitemap不被验证器识别。所以简短的回答是:这行不通。另见此处:WIKI , 哪些语句是允许的。
基本上,让其他搜索引擎知道您有站点地图的最佳方法是将站点地图添加到您的 robots.txt 文件中。
因此,在您的网络服务器根目录中创建一个 robots.txt 文件,如下所示:example.com/robots.txt
然后将以下内容添加到文件中:

Sitemap: http://www.example.com/sitemap.txt
User-agent: *
Disallow:
该文件的内容告诉搜索引擎要抓取哪些页面(以及不抓取哪些页面)以及哪些搜索引擎有权抓取您的网站。拥有此文件很重要,因为当搜索引擎机器人进入您的网站时,它会先查找您的 robots.txt,然后再执行任何其他操作。
澄清命令:

User-agent: Defines, which search engines are allowed to use the robots.txt file. However "bad" engines will still use the file, even if you say no. The * defines, that all engines are allowed to crawl the file.


Disallow: With this statement you can define, which directorys of your website should not be crawled by the search engines e.g. /photos/


希望我能帮上忙!

关于html - 链接到 HTML 纯文本站点地图文件的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68396772/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com