Better error messaging for permalinks with missing trailing slash
This comes up fairly often, most recently at #3379.
Is it worth documenting?
Maybe in Working with Templates > Permalinks > Use template syntax in Permalink or Advanced Usage?
You need to use a trailing slash here or .html extension so that we know you’re outputting an html file
leaving out the trailing slash from permalinks also leads to github pages delivering these transformed mds with content-type
application/octet-streambecause, like zach said, they don't get file-endings this way. so if that happens, check your permalinks.
The example in Dynamic permalinks for a directory of content templates does not have a trailing slash, but maybe that doesn’t matter because it is in a Directory Data File?
Certainly a +1 for an error message or documentation regarding this (Maybe there is documentation now? but I didn't know what was wrong in order to seek it out);
I missed a trailing slash in my pagination of tags setup (Following this guide: https://www.11ty.dev/docs/quicktips/tag-pages/) and without it the Image plugin transform wouldn't work on these generated pages. I spent a while trying to figure out the problem because everything else on the page was seemingly working ok, like the name of the tag itself and the data was coming through.
I feel mighty silly for having missed a single "/", but some kind of error message would have helped narrow it down quicker :)
Eleventy v3.0.0-alpha.21 and v3.0.0-beta.2 will now ship with an error message when templates with a truthy outputPath are missing a file extension.
permalink: falsefinepermalink: fooerrorspermalink: foo/finepermalink: foo/index.htmlfine
Now, this isn’t always an error for every project so you can disable this new error message globally with eleventyConfig.configureErrorReporting({ allowMissingExtensions: true });
The error message looks like this:
[11ty] Problem writing Eleventy templates:
[11ty] The template at './index.html' attempted to write to './_site/foo' (via `permalink` value: 'foo'), which is a target on the file system that does not include a file extension.
[11ty]
[11ty] You *probably* want to add a `.html` file extension to your permalink, so that most hosts will know how to correctly serve this file to web browsers. Without a file extension, this file may not be reliably deployed without additional hosting configuration (it won’t have a mime type) and may also cause local development issues if you later attempt to write to a subdirectory of the same name.
[11ty]
[11ty] Learn more: https://www.zachleat.com/web/trailing-slash/
[11ty]
[11ty] This is usually but not *always* an error so if you’d like to disable this error message, use `eleventyConfig.configureErrorReporting({ allowMissingExtensions: true });`
Added support for eleventyAllowMissingExtension: true data cascade option to skip this error on a per-template (or per-directory) basis.
Temporary docs preview deploying to https://11ty-website-git-v3-11ty.vercel.app/docs/permalinks/#trailing-slashes
Could we also add /_headers to the allowlist, as per Cloudflare Pages?
@groenroos done!