Node version(node -v):
v8.9.4
Your site _config.yml (Optional):
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/
# Site
title: Clarke的博客
subtitle:
description:
author: Clarke
language: zh-cn
timezone: Asia/Shanghai
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://blog.clarke.moe
root: /
permalink: :category/:urlname.html
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: true
relative_link: true
future: true
highlight:
enable: true
line_number: true
auto_detect: false
tab_replace:
# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
path: ''
per_page: 10
order_by: -date
# 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: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: landscape
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type:
Your theme _config.yml (Optional):
Hexo and Plugin version(npm ls --depth 0):
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]
我已经把_config.yml中的relative_link设为true,在md文件中用{% asset_img abc.png %}这样的形式引用图片,但是hexo g生成的网页是用<img src="/123/456/abc.png">这样的形式来引用图片,这是绝对路径,不是相对路径。
恕在下愚钝,/123/456/abc.png不正是相对路径么?绝对路径不应该是http://domain.com/123/456/abc.png么?
https://www.jianshu.com/p/cf740c7960c3
@NoahDragon ,不好意思,可能我没有把我的意思表达清楚。我希望hexo生成的图片链接是基于当前页面的相对路径,比如这种
../123/456.jpg ,而不是这种基于根目录的相对路径 /123/456.jpg ,因为我发现我把博客放在类似 http://domain.com/blog 这种二级目录时它引用不到我的图片。
如果网站是放在子目录下,需要设置_config.yml中的url和root分别为http://domain.com/blog,/blog/。
请试下是否解决问题了。
@NoahDragon ,其实我是故意不设置这个的。因为我希望开启了 relative_link 后,我不管把网站放到哪个域名和哪个子目录下且不需要修改_config.yml,它都能正常打开链接和显示asset里的图片,但是因为hexo程序显示asset图片的链接是以 / 开头,导致这个功能不能实现,希望能改进一下,谢谢。
我也遇到这个问题了,/123/456/abc.png 会链接到绝对路径,123/456/abc.png 则是链接到相对路径。
@necan 这个问题可能要我们自己来解决了。
@necan 这个问题可能要我们自己来解决了。
请问你是怎么解决这个问题的
@necan 这个问题可能要我们自己来解决了。
请问你是怎么解决这个问题的
我没解决,我不用hexo很久了,我也不知道现在最新版还有没有这个问题
Most helpful comment
我也遇到这个问题了,
/123/456/abc.png会链接到绝对路径,123/456/abc.png则是链接到相对路径。