I am trying to host a website in github pages but relative links doesn't work (css is not loaded).
My web page has a base url as follows: user.github.io/website
I have the following generated structure in gh-pages
branch:
.
├── css
│ └── styles.css
├── index.html
The index.html
file has the following:
<!doctype html>
<html lang=en >
<meta charset=UTF-8 >
<link rel=stylesheet href="/css/styles.css">
...
As you can see the link to the style-sheet is /css/styles.css
, so it would go to my parent directory, resulting in the absolute link: user.github.io/css/styles.css
, while the correct path should be user.github.io/
website
/css/styles.css
.
The only way to fix this at the best of my knowledge is to eliminate the /
in the href in the index file:
<link rel=stylesheet href="css/styles.css">
But as I have a lot of links and this is an auto generated html I don't know how to fix this from Franklin.jl, also this could be a error of gh pages configuration too.
CodePudding user response:
From 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.
In other words, it sounds like you're doing a project website, so you need to let Franklin know by setting prepath