如何更改 Franklin.jl 中的相对路径?
How to change relative paths in Franklin.jl?
我正在尝试在 github 页中托管一个网站,但相对 links 不起作用(css 未加载)。
我的网页有一个基础 url 如下:user.github.io/website
我在 gh-pages
分支中有以下生成的结构:
.
├── css
│ └── styles.css
├── index.html
index.html
文件具有以下内容:
<!doctype html>
<html lang=en >
<meta charset=UTF-8 >
<link rel=stylesheet href="/css/styles.css">
...
如您所见,样式 sheet 的 link 是 /css/styles.css
,因此它会转到我的父目录,导致绝对 link: user.github.io/css/styles.css
,而正确的路径应该是user.github.io/
website
/css/styles.css
.
据我所知,解决此问题的唯一方法是删除索引文件中 href 中的 /
:
<link rel=stylesheet href="css/styles.css">
但是因为我有很多 link 并且这是自动生成的 html 我不知道如何从 Franklin.jl 解决这个问题,这也可能是gh 页面配置错误。
来自 here,
In any case, before deploying, if you're working on a project website i.e. a website whose root URL will look like username.gitlab.io/project/ then you should add the following line in your config.md file:
@def prepath = "project"
the publish function will then ensure that all links are fixed before deploying your website.
也就是说,听起来像是在做一个项目网站,所以你需要通过设置prepath
让富兰克林知道
我正在尝试在 github 页中托管一个网站,但相对 links 不起作用(css 未加载)。
我的网页有一个基础 url 如下:user.github.io/website
我在 gh-pages
分支中有以下生成的结构:
.
├── css
│ └── styles.css
├── index.html
index.html
文件具有以下内容:
<!doctype html>
<html lang=en >
<meta charset=UTF-8 >
<link rel=stylesheet href="/css/styles.css">
...
如您所见,样式 sheet 的 link 是 /css/styles.css
,因此它会转到我的父目录,导致绝对 link: user.github.io/css/styles.css
,而正确的路径应该是user.github.io/
website
/css/styles.css
.
据我所知,解决此问题的唯一方法是删除索引文件中 href 中的 /
:
<link rel=stylesheet href="css/styles.css">
但是因为我有很多 link 并且这是自动生成的 html 我不知道如何从 Franklin.jl 解决这个问题,这也可能是gh 页面配置错误。
来自 here,
In any case, before deploying, if you're working on a project website i.e. a website whose root URL will look like username.gitlab.io/project/ then you should add the following line in your config.md file:
@def prepath = "project"
the publish function will then ensure that all links are fixed before deploying your website.
也就是说,听起来像是在做一个项目网站,所以你需要通过设置prepath