I have an Eleventy project based on pug layout files, Markdown template files, built with Parcel V2 and then served by BrowserSync. Everything works fine. Yet, to tidy up my files I'd like to drop my page files into a pages folder (pretty much like some other major frameworks – Nuxt, Next, etc. – do it). But in this case Eleventy builds the pages within the pages folder like so:
pages/index.html pages/subdirectory/index.html
Here is an excerpt of my folder structure:
src/
assets/
includes/
layouts/
base.pug
home.pug
partials/
header.pug
pages/
pages.11tydata.js
index.md
subdirectory/
index.md
And this is the content of my 11data.js file:
module.exports = {
permalink: "{{page.filePathStem | replace('/pages/', '/')}}.html",
}
I was hoping that this ommits the pages part from my URL structure. Only when I change the md-files into njk-files it works! But then unfortunately, the markdown part in those files isn't handled anymore. Does anyone have an idea how I can change my URL structure on the directory level but still use my beloved markdown files with the front matter? Thanks for your help!
I got thisd to work right by using eleventyComputed, which I think may be required for this type of dynamic setting. This is what works for me:
module.exports = {
eleventyComputed: {
permalink: data => { return data.page.filePathStem.replace('/pages/','/') + '.html' }
}
}