DEV Community

hreflang on a static site with clean URLs: the .html mistake

We maintain several small multilingual sites on static hosting. One of them — a shop in Funchal — had a quiet SEO problem that took one line per page to fix.

The setup. Netlify serves /blog/article.html at the clean URL /blog/article and redirects the .html version. The canonical tag pointed to the clean URL. But the hreflang tags still pointed to …/article.html.

Why it matters. Google expects hreflang alternates to point to the canonical, indexable URL. If they point to a redirect, the language cluster is inconsistent and Search Console starts reporting pages "with redirect" and alternate-page issues.

The fix. Make every URL that describes the page agree: canonical, hreflang (including x-default), og:url, structured data url/mainEntityOfPage, internal links and the sitemap — all without .html.

A quick check you can run:

grep -rn 'hreflang' --include=*.html . | grep '\.html"'
Enter fullscreen mode Exit fullscreen mode

Anything it prints is a page to fix.

Takeaway. On static sites, URL rules live in two places — hosting redirects and your HTML. When you change one, search for the other.

We build and maintain multilingual websites for small businesses: weblevo.com

Top comments (1)

Collapse
 
hanin_mp profile image
Hanin Mp •

The grep covers the HTML side, but the sitemap is the one I see missed most after a clean-URL change, since generators often keep writing the old .html paths. One more check worth adding: fetch each hreflang target and confirm it returns 200 without a redirect and links back to the page that referenced it. A missing return link still triggers "no return tags" in Search Console even after the .html fix. Did you see the redirect warnings clear on their own, or did you have to revalidate?