Przejdź do treści głównej
← 📄 HTML & the platform·Moduł A6 · Lekcja 4
ZadanieBuild the head for a blog post that exists at /blog/why-fastapi with self-canonical 'https://learnpython.academy/blog/why-fastapi'. Title 'Why FastAPI', meta description 'A practical case for FastAPI over Flask in 2026.'

kanoniczny: jedyny prawdziwy adres URL

100 XP7 min
Teoria

Why canonical exists

The same content can live at multiple URLs without you meaning it to:

  • example.com/post vs example.com/post/ (trailing slash)
  • https://example.com/post vs https://www.example.com/post
  • /post vs /post?ref=twitter&utm_campaign=launch
  • /post vs /p/123 (alias)

Google sees them as separate pages. PageRank gets split. Each version competes against the others. The fix:

<link rel="canonical" href="https://example.com/post" />

Tells Google "if you found this content at any other URL, treat THIS one as the master copy. Consolidate all rankings here."

Rules

  • Absolute URL. /post doesn't work — must be full https://....
  • Self-referential is fine. /post can have <link rel="canonical" href="https://example.com/post" /> pointing at itself. Even recommended.
  • Cross-domain works. Republished content can canonical-link back to the original.
  • Match the path you want indexed. If your CMS generates ?ref=twitter variants, the canonical should be the clean URL.

hreflang vs canonical

Confusing pair:

  • canonical says "this URL is the master version of these duplicates."
  • hreflang says "this is the EN version; the FR translation lives at /fr/post."

A multi-language page has BOTH: canonical to itself (the EN URL), plus hreflang siblings to its translations.

🔒

Zarejestruj się, aby zacząć kodować

Teoria jest dostępna dla każdego. Edytor, podgląd na żywo i check odblokowują się z 7-dniowym darmowym okresem próbnym — wymagana karta, anuluj w dowolnym momencie.

Zarejestruj się — darmowy okres próbny →

Pierwsze 10 lekcji w każdej ścieżce jest darmowych. Karta nie jest wymagana.

← PoprzedniaNastępna lekcja →

Codziennie jedna wskazówka Python lub web — na maila

Krótko, ręcznie pisane, bez spamu. Wypisanie w jedno kliknięcie.