eleventy
eleventy copied to clipboard
Problems with Eleventy server, passthrough copy, and pathPrefix
Operating system
macOS Sonoma Version 14.2.1
Eleventy
2.0.1
Describe the bug
Hi. Sorry for reporting several issues in one — they all are related to my repro case.
- If Eleventy server is started with the
--ignore-initialoption (e.g. using theeleventy --ignore-initial --incremental --servecommand), then the page that lists elements of a collection (e.g. the index page for a blog) will not show the collection items. It seems that the--ignore-initialoption prevents the full collection from being read. If this is the expected behavior, I do not think it is reflected in the documentation. - The passthrough copy emulation (enabled with
eleventyConfig.setServerPassthroughCopyBehavior("passthrough");) does not seem to work. The default behavior, which iscopy, works correctly - Eleventy does not detect changes in passthrough files.
- If I add a
pathPrefixtoeleventyConfig, the dev sever redirects to a page without the prefix if the url does not have a trailing slash. For example:- No prefix set in the config; url
/blog/2023-article-one/(with a trailing slash) shows the page correctly - No prefix set in the config; url
/blog/2023-article-one(without a trailing slash) redirects to/blog/2023-article-one/and shows the page correctly - Prefix set in the config; url
/prefix/blog/2023-article-one/(with a trailing slash) shows the page correctly - (BUG) Prefix set in the config; url
/prefix/blog/2023-article-one(without a trailing slash) redirects to/blog/2023-article-one/(prefix lost), and shows a 404 page
- No prefix set in the config; url
Reproduction steps
For the problem with --ignore-initial:
- Copy the reproduction repo, install node modules, and run
npm start(this will runeleventy --ignore-initial --incremental --serve) - Update the
src/blog.njkfile - Navigate to
/blog - You will see the "Blog" heading, without any links to the articles. Expected the blog index page to contain a list of articles.
For the problem with passthrough copy:
- Make sure the
builddirectory has been deleted - In
.eleventy.jsfile, uncomment the lineeleventyConfig.setServerPassthroughCopyBehavior("passthrough"); - Run
npm start(this will runeleventy --ignore-initial --incremental --serve) - Save
src/blog/2023/article-one/index.mdfile to get it picked up by the dev server - Open
/blog/2023-article-one/ - (Problem): You will see that the image does not get served
- Stop the dev server
- In
.eleventy.jsfile, comment the line `eleventyConfig.setServerPassthroughCopyBehavior("passthrough"); - Run
npm start - Visit
/blog/2023-article-one/again - You will see that the image has been copied correctly
- Update styles in the
src/blog/2023/article-one/styles.cssfile - In the terminal, you will see the message "Copied 1 file / Wrote 0 files (skipped 5) in 0.02 seconds (v2.0.1)"
- (Problem): However, the dev server will continue serving the old file.
For the problem with pathPrefix:
- In
.eleventy.js, uncomment the linepathPrefix: '/prefix/' - Run
npm startto start the server - Visit
/prefix/blog/2023-article-one/. You should see the blog article page. - Delete the trailing slash from
/prefix/blog/2023-article-one/in the url bar and press enter - (Problem): Instead of redirecting back to
/prefix/blog/2023-article-one/, dev server will redirect to/blog/2023-article-one/(without the prefix), and you will see a 404 page.
Reproduction URL
https://github.com/azangru/eleventy-blog-bugs-repro
Screenshots
No response