I have a `404.md`  in the root directory of the preview site for the Workbench redesign:

- [Repo](https://github.com/pommevilla/incog-workbench)
- [Preview site](https://pommevilla.github.io/incog-workbench/)

When I serve this locally, the 404 page works as expected: going to `http://localhost:4848/fake.html` and `http://localhost:4848/getting_started/fake.html` both show the correctly rendered 404 page and in both cases I am able to navigate away via the sidebar and the navbar.

When I try this on the live preview site, the 404 page correctly renders for [https://pommevilla.github.io/incog-workbench/fake.html](https://pommevilla.github.io/incog-workbench/fake.html) and I am able to navigate away as above. However, when I try [https://pommevilla.github.io/incog-workbench/getting_started/fake.html](https://pommevilla.github.io/incog-workbench/getting_started/fake.html), the 404 page doesn't render correctly and I can't navigate away from the sidebar and the url just keeps piling up as I click around to something like `https://pommevilla.github.io/incog-workbench/getting_started/getting_started/authenticating_users/access_and_security/access_and_security/authenticating_users/access_and_security/secure_sockets.html` - all the links I'm clicking are taken as relative to the directory of the incorrect page. 

I've set `site-url: https://pommevilla.github.io/incog-workbench`. I tried this with and without the `permalink: /404.html` suggested by Github [here](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-custom-404-page-for-your-github-pages-site) and still get the same behavior. 

I looked around and found several places saying that custom 404 pages for subdirectories don't work when served out of the root directory: [here](https://github.community/t/links-on-custom-404-page-broken-when-accessed-from-subdirectory-solved/10443). Since the issue seemed to be around working out of a subdirectory, I copied the repo and hooked that up to a [custom domain](https://incog-workbench.com/), but I'm still getting the same behavior: links like [https://incog-workbench.com/broken.html](https://incog-workbench.com/broken.html) work fine, but links like [https://incog-workbench.com/load_balancing/broken.html](https://incog-workbench.com/load_balancing/broken.html) still lead to the same behavior above.
2021-06-29T21:55:31Z
pommevilla
closed
404 not behaving correctly for subdirectories
https://github.com/quarto-dev/quarto-cli/issues/47