Search code examples
githubyamljekyllgithub-pages

Relative links to a specific file in Jekyll [myfile](blah.md) does not work (also does not work on gh-pages)


I have the problem with relative links to a specific file not working at all both on gh-pages and on jekyll locally. Here is my setup->

i have a directory like this:

/
README.md
README.ja.md

and I do a link like [english](README.md) and [japanese](README.ja.md) both links work on github.com (where they render the README below the code directory structure), but DO NOT work on gh-pages. I tested jekyll locally and it also DOES NOT work. If I move the directory structure around like

/
README.md
japanese/
..README.md

this will work... the link has to change to .[japanese](./japanese/)

I can also make this work on the original directory structure at the top if I do links like this-> [japanese](README.ja) (no more .md)

but then it will NOT work on the normal github.com b/c its not a valid link (since the file README.ja does not exist)

I have tried multiple attempts on jekyll locally, the only one that seems to work is removing the .md, but then it won't work on github

here is my _config file

theme: jekyll-theme-dinky
exclude:
  - "*.yml"
  - "*.yaml"
plugins:
  - jekyll-relative-links
relative_links:
  enabled: true
  collections: true

I want it to actually render versus just load the un-rendered website :( https://ipvsean.github.io/workshops/exercises/ansible_rhel/1.2-adhoc/japanREADME.md


Solution

  • fixed with this commit https://github.com/IPvSean/workshops/commit/17f52069a9f7ae5582b1202092dc75e140400058

    basically this was original

    [![japan](../../../images/japan.png) 日本語](README.ja).
    

    and this is what will work

    ![japan](../../../images/japan.png) [日本語](README.ja).
    

    trying to do something fancy like linking the image as well as the text Japanese made the relative link in Jekyll fail, as soon as I just placed the image next to it, it will work. This made me pull my hair out.