Canonical URL (<link rel='canonical' href='...'>) cho Google biết URL nào là 'bản gốc' khi có nhiều URLs chứa cùng nội dung.
Ví dụ: /products?sort=price và /products?sort=name cùng nội dung → canonical trỏ về /products. Khi nào CẦN:
- URL parameters tạo duplicate (filters, sort, pagination)
- HTTP vs HTTPS, www vs non-www
- Syndicated content (bài viết đăng trên nhiều site)
- Mobile URL khác desktop URL. Nếu không có canonical, Google tự chọn 'bản gốc' — có thể chọn sai. Trong Next.js: dùng
metadata.alternates.canonicaltronggenerateMetadata()
Lưu ý: canonical phải là absolute URL, self-referencing canonical cũng tốt (mỗi trang canonical trỏ về chính nó).
A canonical URL (<link rel='canonical' href='...'>) tells Google which URL is the 'original' version when multiple URLs share the same content. For example: /products?sort=price and /products?sort=name show the same content — the canonical should point to /products. When you NEED it:
- URL parameters creating duplicates (filters, sorting, pagination)
- HTTP vs HTTPS or www vs non-www versions
- Syndicated content (articles published on multiple sites)
- Mobile URLs that differ from desktop URLs. Without a canonical, Google picks its own 'original' — which may be the wrong choice. In Next.js: use
metadata.alternates.canonicalinsidegenerateMetadata()
Note: canonical URLs must be absolute, and self-referencing canonicals (each page pointing to itself) are also recommended.