[hexojs/hexo]修改了 url 和 root 后,有些页面的链接出现了问题

2024-07-23 9 views
4

使用的主题是light, hexo版本如下所示

➜  Blog  hexo -v
hexo: 3.1.1
os: Linux 3.16.0-41-generic linux x64
http_parser: 1.0
node: 0.10.25
v8: 3.14.5.9
ares: 1.10.0
uv: 0.10.23
zlib: 1.2.8
modules: 11
openssl: 1.0.1f
➜  Blog  

出现的问题如图片所示

1 点击"archives"和"about"后的反映如下 2 3

下面是配置信息:

全局的_config.yml文件

# Hexo Configuration
## Docs: http://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: 花瓣奶牛的博客
subtitle:
description:
author: tcstory
language: zh-CN
timezone:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://tcstory.github.io/MyBlog/
root: /MyBlog/
permalink: :year/:month/:day/:title/
permalink_defaults:

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: true
  tab_replace:

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Extensions
## Plugins: http://hexo.io/plugins/
## Themes: http://hexo.io/themes/
theme: light

# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: https://github.com/tcstory/MyBlog.git

这个是主题的_config.yml

menu:
  Home: /
  Archives: /archives
  About: /about

widgets:
- search
- category
- tag

excerpt_link: 阅读全文

addthis:
  enable: false
  pubid:
  facebook: true
  twitter: true
  google: true
  pinterest: true

fancybox: true

google_analytics:
rss:

comment_provider: 

public文件如下

4

回答

7
Home: /
  Archives: /archives
  About: /about

改成

Home: /MyBlog
  Archives: /MyBlog/archives
  About: /MyBlog/about

虽然我觉得这并不是优雅的做法

1

@Xuanwo 谢谢 真的好了,为什么我都没有google到相关的资料呢? 难道大家都没有遇到这个问题?

4

这玩意儿- -,不好查。。你用什么关键字呢。。

3

@Xuanwo 额, hexo archives 吧.................. 还有直接搜索 cannot get /archives 之类的..............

6

我搜的“If your site is put in a subdirectory, set url as”,第一个就是这个网页。。

6

@Xuanwo 刚刚试了下,把站点、主题配置全改了路径的话,about等页面就多加了一层链接了,我觉得next版本的事情吧。

4

@Xuanwo 你好,我用的hexo加上next主题,想达到这样的效果:网址的主页显示网址为我的域名xxxx.me,文章的链接为:xxxx.me/blog/xxxx-xx-xxx-xxx,其他的分别为xxxx.me/about/,xxxx.me/tags/等等。请问该怎么实现呢?多谢了!