4

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?

2 Answers2

1

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?

Mr. Hugo
  • 11,887
  • 3
  • 42
  • 60
  • Thank you for the answer. Solution one does not happen because the actual route for cv.md itself is in `_pages/cv/` where `my_cv.pdf` also is. So the global permalink changes the permalink of the `md` files and not the static_files. – Alireza M. Kamelabad Jun 01 '20 at 12:24
  • Thank you, you are correct. I have updated the answer. – Mr. Hugo Jun 02 '20 at 06:08
  • Well actually they appear and are available even if you put them in an underscore named folder. The trick is to include the path in config. – Alireza M. Kamelabad Jun 03 '20 at 07:06
-1

Unless this is something you plan to roll-out to dozens of sub-directories or dozens of sites, I'd just add the full path to the link. Something like [Download my CV]({{ '/path/my_cv.pdf' | relative_url }}) or [Download my CV]({{ '/path/my_cv.pdf' | absolute_url }}).

Failing that, you could add permalink: /path/where/pdf/lives/ in the cv.md frontmatter. This way they'll both be in the same directory. Of course, this means your cv.md won't build at example.com/cv/.

Brad West
  • 943
  • 7
  • 19