Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Managing Jekyll Pages in Folders (on github-pages)

I have a Jekyll website hosted on GitHub Pages. Now I am having so many pages and I would like to manage them in a folder called _pages. I ideally want to have this structure:

root
  |-> _pages
      |-> Index.md
      |-> contact.md
      |-> cv
          |-> cv.md
          |-> my_cv.pdf
  |-> _posts
  |-> [other things such as config and gemfile]

This I have done defining default permalinks in the _config.yml adding:

include:
  - _pages

defaults:
  - scope:
      path: "_pages"
      type: "pages"
    values:
      permalink: /:basename/ # make URL of pages in the folder _pages as on the root.

That works perfectly.

However, as you see inside the _pages I would like to have another subfolder named cv and put my cv.md and my_cv.pdf in the same folder (in the actual website I have much more of these files for pages.). Ultimately I would like to have a benefit of using [Download my CV](my_cv.pdf) relative local linking, which I suppose because the pdf and the .md file are in the same folder it will recognize it. However it is not the case. cv.md has the permalink of /cv/ and not the cv folder. So when I use [Download my CV](my_cv.pdf) it creates root/cv/my_cv.pdf where this pdf file actually does not exist!

How can I manage to fix this thing? what is your trick?

like image 488
Alireza M. Kamelabad Avatar asked Jan 18 '26 12:01

Alireza M. Kamelabad


1 Answers

You cannot put static files in a directory starting with an underscore. They will not be available in/after the build process:

Which folder should I put my static files in Jekyll?

like image 55
JoostS Avatar answered Jan 20 '26 00:01

JoostS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!