I would like all posts and pages on my Jekyll site to have the same link structure: example.com/my-title
, regardless of the directory structure I use to store my files.
Looking at the documentation it seems like I should be able to implement this by putting the following line in my _config.yml
:
permalink: /:title
.
This almost works. All posts (in the _posts/
directory) get the correct URL. And all pages in my site's home directory also get the correct url. However, pages that are in subdirectories still have the directory path prefixed to the url. For example, if I have a page pages/cats/my-cat.md
the URL is example.com/pages/cats/my-cat
, instead of what I want (example.com/my-cat
). If I set the permalink for that page directly in the front matter as /my-cat
I get the desired outcome, but I'd rather not do this on every page.
Is it possible to remove the path from all page URLs?
I see a number of other questions about Jekyll permalinks but nothing that addresses this exactly. This answer from 2013 says that pages will "always remain relative path" but that's fairly old, and also seemed like a throwaway assertion rather than an evidence-backed claim.