Hreflang
Hreflang Attribute
An HTML attribute telling search engines which language and region a page targets, preventing duplicate content across locales.
技术细节
The hreflang tag (link rel='canonical') tells search engines which URL is the authoritative version when identical content exists at multiple URLs. Common scenarios: www vs non-www, HTTP vs HTTPS, URL parameters, and paginated content. Canonicals are hints, not directives — Google may ignore them if signals conflict. Self-referencing canonicals on every page are a best practice. Cross-domain canonicals consolidate ranking signals from syndicated content back to the original source.
示例
```html
<!-- Prevent duplicate content issues -->
<link rel="canonical" href="https://peasytools.com/tools/image-resize/">
<!-- Self-referencing canonical (best practice for every page) -->
<link rel="canonical" href="{{ request.build_absolute_uri }}">
```