When using Parcel to build and/or serve a website made of static HTML files, linking to directories doesn't work as expected. Example:
<a href="about/">About</a>
N/A - bug is visible without any configuration files.
It should generate dist/about/index.html, and clicking the "About" link should go to http://localhost:1234/about/ -- which should serve the content from about/index.html.
It does not generate dist/about/index.html, and clicking the "About" link goes to http://localhost:1234/about/ -- but it serves the content from index.html.
Generate index.html files found in a directory, and serve their content when visiting that directory URL directly.
I came upon this bug when trying to make a simple marketing website: primarily HTML and CSS, very little JS, and not a single-page applicatino.
https://github.com/Kerrick/parcel-problems
Simply run parcel serve index.html and click the links to see the inconsistent behavior.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.8.1
| Node | v10.1.0
| npm/Yarn | yarn 1.5.1
| Operating System | macOS 10.13.4
This is because parcel detects this syntax as front-end routing or a custom back-end route instead of a html file if I'm not mistaken.
Not sure if we should fix this, not that hard to add index.html to the href property
not that hard to add index.html to the href property
It isn't hard to add, but it has negative side effects: after clicking the link, the browser bar shows an ugly URL (example.com/about/index.html) instead of the desired pretty URL (example.com/about/). I wouldn't mind _writing_ index.html in the href if the final output omitted it.
As it stands, it's impossible to do standard "pretty URLs" with Parcel and static HTML files. I'd definitely consider that a bug.
Intresting, I'll change this to RFC/Feature
I ran into the same problem. I found this: https://github.com/parcel-bundler/parcel/blob/060db2e2c56f08e223e9a9075035f0998e249763/packages/core/parcel-bundler/src/Resolver.js#L252-L253 and while it sounds very similar it doesn't seem to apply to this problem.
My current work-around is to:
$ parcel build index.html subdir/index.html
and have parcel ignore <a href="./subdir">Go to subdir</a> in the top-level HTML file but I'd like parcel to figure this out on its own and just specify one target.
I have a same problem...any updates?
Most helpful comment
It isn't hard to add, but it has negative side effects: after clicking the link, the browser bar shows an ugly URL (
example.com/about/index.html) instead of the desired pretty URL (example.com/about/). I wouldn't mind _writing_index.htmlin thehrefif the final output omitted it.As it stands, it's impossible to do standard "pretty URLs" with Parcel and static HTML files. I'd definitely consider that a bug.