Netlify pretty urls won't strip .html extension

I am trying to deploy a static website. I have activated the pretty url option but all my pages are still available with the .html, or /index.html for directories, in addition to the url-less version.

I have read in the docs about redirects and rewrites that url prettifying should be handled via this option, but I can’t make it work and having both urls, with and without extension is really bas SEO-wise.

What am I missing?

PS: site name --> laughing-swirles-e5cbea.netlify.app
Thanks :slight_smile:

There is no way to prevent us from serving the .html URL if someone types it in. The idea is, you don’t publish that URL, nobody finds it, and thus you have no duplicate content problems.

The Pretty URL’s feature just REWRITES your html and js and css to link to /file instead of /file.html. We’ll still serve both, with or without the feature enabled.

Thank you for your answer. That clarifies things as the Pretty URL feature seemed to do nothing.

Could I use the redirect directives to 301 redirect the urls with extension to the extensionless ones?

hey Buzut, we’re still looking in to this issue and will get back to you soon with some updated recommendations :+1:

1 Like

Hey @buzut, if you have Pretty URLs enabled, people will not get to the .html versions of your pages from your site since we rewrite the HTML of your site to strip the .html extension away. They would only get to those pages if they type them in directly. You could try adding a 301 redirect for every file ending in .html, but it seems like a lot of work for minimal benefit. For each article or post, you’d have to do something like this, and even then you may hit an infinite loop problem since you’re redirecting to the same page:

/article.html   /article   301!

This is also not something our redirects would parse:

/*.html   /:splat   301!

Since you’re thinking about SEO, I did want to share this post by our CTO about a canonical link header we rolled out for when you enable a custom domain on your site- might be of interest to you :slight_smile: :

Hope this helps! Please let us know if we can answer any other questions on this.

1 Like

Hi Team,

pretty url is enabled, yet it doesn’t serve the page without .html

See live urls:
Works: https://amp.houseofcandy.in/product-category/store.html
Doesn’t work: https://amp.houseofcandy.in/product-category/store

Please help.
What am I missing?

Hi, @intellemo, I looked at the files for the site. These are the names:

/product-category/store.html.html
/product-category/marshmallow.html.html
/product-category/gums-and-jellies.html.html
/product-category/chocolates.html.html
/product-category/fizzy.html.html
/product-category/lollipops.html.html
/product-category/hard-boil.html.html
/product-category/gift-boxes.html.html
/product-category/merchandise.html.html

To summarize, the pretty URLs setting is removing one .html and the issue here is that there are two .html strings to remove (not one).

Please rename these files (for example from /product-category/store.html.html to /product-category/store.html) and this will resolve the issue.

You can download deploys with the button shown in this screenshot to confirm this:

download-deploy-button-small

If this doesn’t fix it or if there are other questions, please reply anytime.

It worked.
Thanks a lot. :slight_smile: