修改hexo+next, 使得url路径带.html后缀 部署到阿里云oss |
您所在的位置:网站首页 › plugin标签里的url › 修改hexo+next, 使得url路径带.html后缀 部署到阿里云oss |
阿里云oss部署hexo不支持自动跳转到index.html页面,所以如果需要部署到阿里云oss上,那么需要做以下修改。 创建“标签”页面 生成 tags.html新建“标签”页面 hexo new page tags 复制代码给标签页面添加类型 我们在source文件夹中的tags文件夹下找到index.md文件,在它的头部加上type属性。 --- title: tags date: 2018-08-06 22:48:29 type: "tags" #新添加的内容 --- 复制代码将index.md文件重命名为 tags.md并挪到 tags的父文件夹下,删除tags文件夹 创建“分类”页面 生成categories.html这里和上一步骤基本一致 新建分类页面 hexo new page categories 复制代码给分类页面添加类型 我们在source文件夹中的categories文件夹下找到index.md文件,在它的头部加上type属性。 --- title: 文章分类 date: 2017-05-27 13:47:40 type: "categories" #这部分是新添加的 --- 复制代码将index.md文件重命名为 categories.md并挪到 categories的父文件夹下,删除categories文件夹 创建about.html参考以上两个步骤 文章页面在_config.yml中,修改 permalink: :year/:month/:day/:title/ 复制代码为 permalink: post/:urlname.html 复制代码其中 urlname为在文章中指定当前文件的永久链接,如 --- title: 修改hexo+next, 使得url路径带.html后缀 date: 2018-04-21 23:55:07 categories: [hexo设置] tags: [hexo] urlname: hexo-next-url-html-suffix --- 复制代码 修改文章归档首页的访问地址修改 主题文件夹下的 _config.yml 配置文件 menu: home: / || home tags: /tags.html || tags categories: /categories.html || th archives: /archives/index.html || archive about: /about.html || user 复制代码这里修改之后会出现 点击归档页菜单栏的时候 菜单没有处于选中状态 修改 主题文件夹下 scripts/helpers/engine.js var current = this.url_for(canonical).replace('index.html', '', 'g'); 复制代码为 var current = this.url_for(canonical); 复制代码问题解决 修改hexo的分页 %d/index.html 变为 %d.htmlhexo生成的分页 静态文件路径 如 archives/page/2/index.html 修改成 archives/page/2.html 修改 node_modules/hexo-pagination/lib/pagination.js //var format = options.format || 'page/%d/'; var format = 'page/%d.html'; 复制代码 修改分页插件生成的分页链接
修改 node_modules\hexo\lib\plugins\helper\list_categories.js const suffix = options.suffix || 'index.html'; 复制代码 修改标签页的链接 形如 tags/Spring-Cloud/index.html修改 node_modules\hexo\lib\plugins\helper\tagcloud.js result.push( `${transform ? transform(tag.name) : tag.name}` ); 复制代码 修改文章内容页里的 分类和标签 链接修改 主题文件夹下 layout/_macro/post.swig 复制代码 # {{ tag.name }} 复制代码到这里,所有的链接都是以 html后缀 打开 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |