Skip to content

[Bug]: page.dir not working in posts #9665

@Marro64

Description

@Marro64

Operating System

Windows 11 Pro 23H2

Ruby Version

ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x64-mingw-ucrt]

Jekyll Version

jekyll 4.3.3

GitHub Pages Version

Latest

Expected Behavior

When inputting {{ page.dir }} in a post, I expect it to be replaced by the path between the source directory and the file of the post, as outlined in the page variable documentation.

Current Behavior

When inputting {{ page.dir }} in a post, it gets replaced with empty (as in, it gets removed with nothing put in its place.) When putting {{ page.dir }} in a file which isn't a post, it behaves as expected. This appears to happen even on a clean install of Jekyll with no modifications other than creating a post which references {{ page.dir }}

Relevant log output

No response

Code Sample

Observe issue in existing repository:

The issue can be observed on my WIP website: https://marro.dev/blog/page-dir-variable-broken-in-jekyll
The website repository can be found at: https://github.com/Marro64/Marro64.github.io

Steps to reproduce the error:

The issue can be observed when creating a new Jekyll project and editing the template post.

  1. (Optional) Open a Windows Sandbox instance and install Jekyll according to the Windows install instructions in the documentation
  2. Create a new site using jekyll new myblog and navigate into its folder using cd myblog
  3. The previous step might have resulted in an error due to issue 9615, edit the Gemfile to comment out line 29 (gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]) and run bundle install to apply the change
  4. Edit the template post (named something similar to \_posts\2024-09-06-welcome-to-jekyll.markdown, replace the part below the Front Matter with:
The part inbetween square brackets should show the contents of page.dir ([/] in this case): [{{ page.dir }}]

And as a control variable, the part inbetween square brackets should show the contents of page.url ([/welcome-to-jekyll.html] in this case): [{{ page.url }}]
  1. Run the Jekyll testing server using bundle exec jekyll serve and open the testing site in a browser, navigate to the edited template post

Here you can observe that the output of {{ page.dir }} is incorrectly empty, whereas the output of {{ page.url }} is correct.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions