Hello! I’m trying to accomplish the task of linking to files within a collection from a post. However, I’m having an issue that relates to the collection having subdirectories, and those subdirectories having spaces in their names.
Here’s a simplified example of how my site source is layed out:
├── 404.html
├── about.md
├── _config.yml
├── Gemfile
├── Gemfile.lock
├── index.md
├── _labs
│ └── Lab 01 Introduction
│ └── PS01 source.html
├── _posts
│ └── 2020-01-01-test_post.md
The post 2020-01-01-test_post.md
contains the following markdown:
---
layout: post
title: "Introduction"
author: "Will Hopper"
---
[Link]({{ site.baseurl }}{% link _labs/Lab 01 Introduction/PS01 source.html %})
So far so good, and running jekyll serve
succeeds just fine, meaning it can find the linked file at build time. The issue arises later, with the way jekyll has handled the spaces in the Lab 01 Introduction
directory. Here is the contents of the _site
folder after building:
└── _site
├── 404.html
├── about
│ └── index.html
├── assets
│ ├── main.css
│ └── minima-social-icons.svg
├── feed.xml
├── index.html
├── labs
│ └── Lab%2001%20Introduction
│ └── PS01 source.html
└── posts
└── test_post.html
As you can see, the spaces in the filename have been replaced with the URL encoded escapes, %20
. As a result, the link in the post 404’s.
I tried replacing the “raw” name of the folder with the URL encoded output, i.e., I tried {% link _labs/Lab%2001%20Introduction/PS01 source.html %}
but now the site fails to build with Liquid Exception: Could not find document
.
In case it’s important, this HTML file is effectively a static file (i.e., it has no front matter).
A curious complement to this, Jekyll seems to leave spaces in the filenames alone? Any ideas on what I could change to get this working correctly, without removing all the spaces?
Thanks in advance for the help!