jekyll BASE_PATH doesn't work

826 Views Asked by At

create a repo in ithub "github.com/name/blog".in the _config i set BASE_PATH = ""name.github.io/blog", but it dosen't work",when visit the "name.github.io/blog/", find the probleam, css and js get failed, for example style.css request url "name.github.io/assets/themes/sext-v/css/style.css", it should be "name.github.io/blog/assets/themes/sext-v/css/style.css".

1

There are 1 best solutions below

0
On

If I understand correctly, you have 2 Github repos: name.github.io and blog. You will be able to visit the blog repo at name.github.io/blog and you're wondering how to reference JS and CSS files from the blog repo, rather than the name.github.io repo?

A solution is to set baseurl: "/blog" in your _config.yml file. Now throughout your site, / will (still) point to the name.github.io root, but you can reference the blog JS and CSS files by putting {{ site.baseurl }} into their references: {{ site.baseurl }}/assets/themes/sext-v/css/style.css

Another is to hardcode in the /blog to the address /blog/assets/themes/sext-v/css/style.css. The reason you need this is that github pages is serving name.github.io as the root directory. If you want assets from somewhere else you'll need to specify that.