Support Forums

Pretty URL in Asset optimization not working

I recently enabled asset optimization through netlify in my website but the Pretty URL function does not work as it still displays the .html extensions in every page. Is there something that I am doing wrong?

Thanks in advance,

Hi @dk-raw,

Pretty URL removes the .html extension from links in your HTML pages. Meaning <a href = "/foo.html">...</a> would become <a href = "/foo">...</a>. It doesn’t change what’s displayed in the address bar.

Is there a way to do that through Netlify though?

Not really unfortunately. You can read this detailed guide here:

I also wanted to know what is the point of Pretty URLs if the only difference is in the source code?

Most users might navigate in your website’s pages through the links on the website. So, it’s useful to make it consistent and force all links in the HTML to point to the same-styled destination.

But, Netlify will still serve the page when it’s requested directly with the .html extension. If that’s not done, it would return in 404s as each client might request the page differently. One might request with /, other might request without it and some might request with .html. Each of those clients needs to see the page instead of a 404 error.

1 Like