昨天需要向Google提交站点地图,目的是为了让Google收录我的博客,方便被搜索到。在经过注册,验证网站等一番努力结束之后就差提交sitemap.xml了,这时候出了问题。
Google Search Console 在我提交了站点地图之后报了10多个网站错误,提示信息显示 “不允许的网址”,然后我看了Google的官方解决方法如下图:
欢迎交流~指正~
我多次反复确认我的网站提交信息没有错误之后在网上也找了很多资料,但是始终报错。
我开始担心hexo 在编译的过程中会不会把验证文件或者sitemap文件修改了导致错误,后来在GitHub上比较了提交前
后的代码发现并没有变化。
后来参考了一篇博文 Hexo博客提交搜索引擎
修改了node_modules/hexo-generator-sitemap/sitemap.xml
如下:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://dhfs.github.io/schemas/sitemap/0.9">
{% for post in posts %}
{{ (config.urlforgoogle+post.path) | uriencode }}
{% if post.updated %}
{{ post.updated.toISOString() }}
{% elif post.date %}
{{ post.date.toISOString() }}
{% endif %}
{% endfor %}
</urlset>
(config.urlforgoogle+post.path)
中的urlforgoogle可以随便定义
只要在网站配置文件_config.yml
配置对应的地址就可以
urlforgoogle: http://dhfs.github.io/
sitemap:
path: sitemap.xml
重新部署提交,再回到Google 提交网站地图,问题解决!