fluid-dev / hexo-theme-fluid

:ocean: 一款 Material Design 风格的 Hexo 主题 / An elegant Material-Design theme for Hexo
https://hexo.fluid-dev.com/
GNU General Public License v3.0
7.05k stars 1.11k forks source link

与 hexo-generator-sitemap 配合使用时,关于页面地址不规范:/about/index.html,影响 SEO #1037

Closed AnzhiZhang closed 5 months ago

AnzhiZhang commented 6 months ago

请确认

问题描述

hexo-generator-sitemap 共同配合使用时,关于页的站点地图生成了 /about/index.html,实际的规范网页应该是 /about/。由于不确定是主题的问题还是该插件的问题,故寻求帮助。 我查看了 db.json,个人页面的 path 也是 about/index.html

"path":"about/index.html"
AnzhiZhang commented 6 months ago

相关 issue:hexojs/hexo#1306

mobeicanyue commented 5 months ago

后缀可以去的吧,如果你不想显示 .html 在 _config.yml

permalink_defaults:
pretty_urls:
  trailing_index: false # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: false # Set to false to remove trailing '.html' from permalinks

image

AnzhiZhang commented 5 months ago

后缀可以去的吧,如果你不想显示 .html 在 _config.yml

permalink_defaults:
pretty_urls:
  trailing_index: false # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: false # Set to false to remove trailing '.html' from permalinks

可以工作,但是为什么只有关于页面有此后缀?

mobeicanyue commented 5 months ago

我没有这个问题。估计是你魔改了什么地方。你新建一个hexo项目,然后装上主题配置这个选项再看看。

AnzhiZhang commented 5 months ago

我没有这个问题。估计是你魔改了什么地方。你新建一个hexo项目,然后装上主题配置这个选项再看看。

fluid 的官方博客也有这个问题 https://hexo.fluid-dev.com/sitemap.xml

mobeicanyue commented 5 months ago

我没有这个问题。估计是你魔改了什么地方。你新建一个hexo项目,然后装上主题配置这个选项再看看。

fluid 的官方博客也有这个问题 https://hexo.fluid-dev.com/sitemap.xml

https://blog.ovvv.top/sitemap.xml 我没发现有啥问题,可能作者是做了一些不向下兼容的改动然后没彻底升级,我是上星期新安装的

AnzhiZhang commented 5 months ago

https://blog.ovvv.top/sitemap.xml 我没发现有啥问题,可能作者是做了一些不向下兼容的改动然后没彻底升级,我是上星期新安装的

你的 pretty_urls 是否都是 true?我的 hexo, fluid, sitemap 都是最新版本

mobeicanyue commented 5 months ago

image

我代码开源的,你直接看吧https://github.com/mobeicanyue/mobeicanyue.github.io

AnzhiZhang commented 5 months ago

后缀可以去的吧,如果你不想显示 .html 在 _config.yml

permalink_defaults:
pretty_urls:
  trailing_index: false # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: false # Set to false to remove trailing '.html' from permalinks

可以工作,但是为什么只有关于页面有此后缀?

改为 false 当然就没有了,这个问题仅在为 true 时出现

mobeicanyue commented 5 months ago

你的问题 我研究了一下没发现问题根源。 ~我是为了美观就移除了 'index.html' 后缀 感觉不好看~

AnzhiZhang commented 5 months ago

你的问题 我研究了一下没发现问题根源。 我是为了美观就移除了 'index.html' 后缀 感觉不好看

问题是不设置 pretty_urls,使用这个主题和 sitemap,在且仅在关于页面添加了 'index.html'。关于 db.json 的观察也印证了这一点,这个问题一定是主题或 sitemap 导致的,我高度怀疑是主题导致的是因为这个主题添加了关于页面,所以在这里报告了问题。

你的方案是个 workaround 但不是 solution,如果不能提供建设性的意见,就不要再发 spam 了,这会影响社区贡献者对问题的判断和定位。

mobeicanyue commented 5 months ago

你的方案是个 workaround 但不是 solution,如果不能提供建设性的意见,就不要再发 spam 了,这会影响社区贡献者对问题的判断和定位。

。。。确实可能是主题的问题 因为主题教程明确要求添加 about 页面,而不是我说的 你魔改了什么地方 我事先看不到你源码,不知道你是什么情况,就给出我认为可以的方案(改pretty_urls)和想法。 在社区并未有明确讨论的情况下,我觉得探讨一下未必不是一种求解和 debug 的过程,也未必不能给 author 提供排查思路和想法 如果你觉得是 spam 那我无话可说

zkqiang commented 5 months ago

可以工作,但是为什么只有关于页面有此后缀?

这是因为 about 是通过创建 about/index.md 生成出对应的 */index.html,同样你创建其他自定义页面 index 也会如此。

这个生成是 hexo generator 自己的工作逻辑,主题并没有对这部分做任何中间处理,所以目前也只有通过 hexo 提供的 pretty_urls 配置来修改

AnzhiZhang commented 5 months ago

这是因为 about 是通过创建 about/index.md 生成出对应的 */index.html,同样你创建其他自定义页面 index 也会如此。

posts 页面没有 /index.html 后缀也是 hexo 的工作逻辑吗,还是主题做了处理?

zkqiang commented 5 months ago

posts 页面没有 /index.html 后缀也是 hexo 的工作逻辑吗,还是主题做了处理?

也是的,主题不会去处理这个逻辑