The copy-paste problem

Every page needs meta tags. Copy-pasting them into each page works until one page is missed. Then search engines and social previews show the wrong thing.

Frontmatter as source

Put seo in the page frontmatter:

  • title
  • description
  • canonical
  • ogType
  • ogImage
  • twitterCard

Then a single component reads that data and renders the tags.

One component

A Seo.svelte component takes data and pathname, builds the tags, and renders them in <svelte:head>. Every page imports it once. No duplication.

Summary

Meta tags are data, not layout. Put them in frontmatter and render them from one place.