JoeyBling / hexo-theme-yilia-plus

一个简洁优雅的hexo主题 A simple and elegant theme for hexo.
https://zhousiwei.gitee.io/yilia-plus-demo/
MIT License
734 stars 172 forks source link

能不能将文章内的链接的绝对路径改成相对路径 #28

Closed yansheng836 closed 4 years ago

yansheng836 commented 4 years ago

Feature Request

如果是绝对路径,不方便部署到自己的服务器中,会导致很多文件丢失。

举个例子,这个是相对路径: https://github.com/JoeyBling/hexo-theme-yilia-plus/blob/fb6c8896b8201063db5e764206e6678471bddbcb/layout/_partial/css.ejs#L1

生成HTML后会变成这样/./main.826e88.css,尝试去访问public里面的文件就会发现很多类似的问题。

JoeyBling commented 4 years ago

不推荐使用相对路径,会存在许多不可预计的问题,所以主题基本上所有的链接我都改成了绝对路径。

你应用服务器是用的什么,nginx吗?贴下配置我看看

JoeyBling commented 4 years ago

比如哪些文件丢失了,线上测试URL贴下我看看

yansheng836 commented 4 years ago

额,不好意思,我发现应该是我的问题,之前忘记了如果博客文件在二级目录是需要该这个配置的

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
#url: http://yoursite.com
url: http://yoursite.com
root: /

修改后就没有问题了。