Closed lenkva closed 1 year ago
Thanks for this thorough analysis. I believe this is due to the source option being systematically passed to Jekyll. Ideally we should check the content of _config.yml
to check for a value. Happy to review a PR doing this.
As a workaround, I've specified the jekyll_src
and build_dir
.
This causes the action to look for the config file in ./<jekyll_src>/_config.yml
rather than the working directory, so I've added a step to copy the _config.yml
into the source directory:
https://github.com/dxw/terraform-code-playbook/blob/main/.github/workflows/build-test.yml#L32-L43
Example Repository for this issue: https://github.com/lenkva/jekyll-source-demo
Expected Behavior
If I include a source property in my Jekyll config, building my page locally searches for files to process, such as included files, relative to that path.
In the example linked above, I have a separate directory named "source", and have configured the Jekyll
_config.yml
to use that directory as source. Link to the config lineWhen I build the page locally, that directory is used as a source directory. All files in it are processed and moved to the same place in the _site output directory as their location relative to the source directory.
I would expect the Jekyll action to show the same behavior and process files relative to the source directory from the Jekyll configuration.
Current Behavior
When running the action, it ignores the
source
property. This results in one of two scenarios:Error
If there are references to things like includes or sass partials, Jekyll will be unable to find them and produce an error.
In the example repository above, this can be seen in this workflow run where I added an include to the index file and the action produced the error
Of note here is that it searches for the
_includes
directory in the root of the repository, rather than the source subdirectory configured as stated above.Incorrect directory structure
If there are no references to produce errors, the Jekyll build will simply run from the root directory and process (and copy) all files in it.
In the example repository, this branch contains such a structure. Its output can be seen in the
gh-pages
branch at this commit: Feed and License are copied over, thesource/index.html
file is transferred directly to that path.Workaround
The workaround would be to set the
jekyll_src
parameter of the action.However, the config.yml will need to be included in that source directory as well, otherwise it will not be processed at all. This can be seen in this workflow run, where the Jekyll action does not find any config file, as there is no such file in that directory.
Steps to Reproduce
I created a live example repository for this bug:
https://github.com/lenkva/jekyll-source-demo
You can reproduce those steps yourself:
Context (Environment)
We had moved our site's content to a subdirectory, because we felt that the root directory was getting too cluttered. We used the config option
source
to point Jekyll at the correct source directory. It worked locally, and we assumed it would work the same online.When we later tried to deploy the site, we got the file inclusion error mentioned above. I experimentally set the
jekyll_src
parameter, and found that the styling was messed up. I also noticed that the CNAME file had been overwritten and wasn't being transferred accurately anymore.Applying the suggestion of forcing the inclusion of CNAME mentioned in other issues here didn't work, because that config was never processed. Likewise, other configurations we had made were ignored. Our Jekyll config explicitly excludes all pure
*.css
files from being processed, so as to force the use of SCSS. The output of the online build, however, processed dummy files we had created to silence misplaced IDE warnings instead of the actual files, leading to the styling issues.It seems odd that the action should ignore the source setting. Even if the workaround of placing the config file in the source directory and setting that as the
jekyll_src
value works, I feel that the Action should mirror the behavior of a local build.