I have disabled Pretty URLs for unruffled-sinoussi-fbd7d8.netlify.app (primary domain is tinyapps.org), but .html-less continue to work and be indexed by search engines, causing duplicates to appear in search results, e.g., this Kagi Search returns two results for the same page, one with the .html extension and one without. Is it possible to return a 404 or 301 for such pretty links? If not, what is the best way to handle this while maintaining normal .html extensions? Thank you.
You can add a canonical tag: rel=canonical: the ultimate guide to canonical URLs • Yoast
Thank you for your kind reply, hrishikesh. Is there not a way to prevent the pretty URLs from being generated? I’ve disabled the feature, and yet the links continue to exist. Or could a general 301 be set up in _redirects that adds an .html extension to any file without an extension?
You can use Edge Functions to handle this:
but not with simple _redirects.
Thanks, @hrishikesh - I’ll look into those. Can you please tell me why there is even an option to enable or disable Pretty URLs (Site Configuration > Build & deploy > Post processing > Pretty URLs) when disabling them apparently does nothing?
I think you may be confused about what that option does.
I think that turning it off does not prevent us from serving:
when you publish https://site.com/file.html
So: turn it off, but don’t publish both URL’s and indexers won’t find them both and you won’t have any SEO penalty, which is most folks’ concern from having both work (or use the rel=canonical trick)
Thanks for taking the time to reply here, @fool. Sadly, the previously-unknown-to-me Pretty URL feature must have been on for some time, as search engines have apparently indexed the .HTML-less links as well. It would be swell if those links did not exist at all (or at least could be redirected via regex to their .HTML originals); I try conserving every byte, and even the extra ~100 bytes per page with a tag that should not be necessary seems wasteful. But I certainly understand that my position is somewhat of an edge case (to put it mildly ;-).