Using Clean URLs

Clean URLs can take hours of work, or massive amounts of boilerplate configuration, on other platforms or servers. Publish your site on Surge, and they will work automatically:

  • /hello-world automatically serves /hello-world.html
  • /foo/bar/ automatically redirects to /foo/bar if /foo/bar/index.html isn’t present, but /foo/bar.html is
  • /foo/bar automatically redirects to /foo/bar/ if /foo/bar.html isn’t present, but /foo/bar/index.html is
  • www.example.com automatically redirects to example.com, or vice versa
  • http://example.com can be redirected to https://example.com

Clean URLs on Surge are optimised for search engines, too. These properly setup redirects ensure your pages have one, canonical source. Plus, your www URL automatically redirects to your root domain (or vice versa).

Everything published on the Surge CDN automatically gets clean URLs. To take advantage of them, publish your project.