Ruixiang's blog

work harder, study better, do faster, become stronger

0%

解决搭建博客中tags和categories页面404

问题:

使用 hexo + next-theme + Github Page搭建博客在收尾阶段碰到一点小问题,菜单栏的TagsCategories 链接无法正常显示,而是直接跳转到404页面。

解决方法:

  • hexo 默认 source 文件中是没有 tagscategories 对应的page文件的,我们需要先手动进行创建,使用命令行:

    1
    2
    hexo new page categories
    hexo new page tags
  • 接下来设置在source 目录下的tags\index.mdcategories\index.md 文件。 在文件最上方的 front-matter(顶部代码片段)中加上对应的type 类型。 比如对于tags\index.md 加上 type: tags, 对于categories\index.md加上 type: categories


  • 测试: 使用 hexo new xxx 新建一个博客文章,在文件最上方的 front-matter(顶部代码片段)中加上对应的tagscategories, 比如:

    1
    2
    tags: hello world
    categories: hello world

  • 使用 hexo g重新生成静态文件,再重新部署 hexo d,打开博客,可以看到菜单中 TagsCategories 成功生成。

Welcome to my other publishing channels