Serve /about from about.html with the clean-URLs option

AddedCDNv0.0.114

Add the line # ee:clean-urls on to your _redirects file and an address like /about serves about.html directly, with no redirect. For sites that build page.html files instead of a folder per page. Level 0 sites only.

Some site generators write each page as a flat file, about.html, but link to it as /about. Until now the edge served /about only if a file existed at exactly that path, so those links needed a rule each in _redirects.

Add this line anywhere in your _redirects file:

# ee:clean-urls on

and a request for /about serves about.html when your site has it. Quartz, Observable Framework, vite-ssg and Hono’s static site helper work this way by default, as do VitePress, Rspress, VuePress and HonKit with their own clean-URLs option turned on.

How it behaves

  • It’s a rewrite, not a redirect. The visitor stays on /about, which is the address your own links use.
  • Your own rules come first. An explicit rule for a path wins. Then clean URLs are tried, then the trailing-slash option if you use it. With both on, /about serves about.html where it exists and moves to /about/ where it doesn’t, so a site can switch pages to folders one at a time.
  • /about.html still serves. Let your generator’s canonical tag say which address is preferred.
  • /about/ doesn’t fall back to about.html. That would give every page a third address.
  • A real file at the path wins. If your site has both LICENSE and LICENSE.html, /LICENSE serves LICENSE. (Before v0.0.115 it served the .html file.)
  • about.html counts as a real page at /about. A catch-all rule such as /* /404.html 404 doesn’t hide it. A forced (!) rule still wins, as it does over any real file.
  • Level 0 sites only, like everything in _redirects.

The line is a comment, so the same file still works unchanged on Netlify or Cloudflare Pages.

← All changes · More CDN changes · Subscribe to CDN