How do I generate a Jekyll site such that its destination is not the `_site` directory?

github jekyll websites

I’ve been asking the question in the title for a little while, in a couple of ways. It turns out it is easy to change the default directories when using Jekyll for static site generation.

From Jekyll: configuration options, you can use the -d, --destination DIR flags to change the destination directory. For me, I wanted the destination to be docs/, so did the following:

$ jekyll serve -d docs/
   Configuration file: **/amy-tabb.github.io/_config.yml
   Source: **/amy-tabb.github.io
   Destination: **/amy-tabb.github.io/docs

And the first three lines of output print the configuration file, source, and destination directories.

I just had this thought: “well, docs/ does not begin with an underscore (_), will docs/ then get generated and create this loop of docs/ in the generated site”?

From experimentation, no. And here’s this from Jekyll: configuration options:

Destination folders are cleaned on site builds

The contents of <destination> are automatically cleaned, by default, when the site is built. Files or folders that are not created by your site will be removed. Some files could be retained by specifying them within the <keep_files> configuration directive.

Do not use an important location for <destination>; instead, use it as a staging area and copy files from there to your web server.

Ok, now, why would anybody want to change the destination directory, if that person is using GitHub pages?

The answer is: when using a non-supported Jekyll plugin, I’ll have to generate the site locally and push it to GitHub (supported plugins, here: GitHub: Supported plugins and versions ). Where will your source files live? Good question. I’ll deal with parts of this problem in a future TIL.

© Amy Tabb 2018 - 2023. All rights reserved. The contents of this site reflect my personal perspectives and not those of any other entity.