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.
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.
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 :
Hope this helps! Please let us know if we can answer any other questions on this.
I’m wondering what should our internal links look like?
I have pretty URL enabled which makes /about serve contents of /about.html.
My users aren’t typing in the links with .html extension, but the links I give them internally have the extension.
If I strip .html extension from all the internal links, the production site on netlify works perfectly, but it makes the development setup unusable because none of the links work without the extension (locally).
Any suggestions?
I’m using a basic webpack based static site boilerplate to build my site.
Hi, @prateekkish. Are you using netlify dev for the local development setup? If not, would you please try using that and let us know if it works or not?
Thanks for this, I was using a super basic live server extension before where I would need to manually add the html extensions back to my links in development. I should’ve been using the Netlify CLI this whole time . Now I can test my preprocessing on the dev side too!