HEEx component that renders SEO meta tags from a PageMeta struct.
Render in your root layout:
<head>
<PhoenixPageMeta.Components.MetaTags.default page_meta={@page_meta} />
<.live_title>{@page_title}</.live_title>
</head>Renders: description, Open Graph (og:type, og:url, og:title,
og:description, og:image, og:image:alt, og:site_name, og:locale,
og:locale:alternate), Twitter Card (twitter:card, twitter:title,
twitter:description, twitter:image, twitter:site), JSON-LD,
canonical URL, and hreflang alternate links.
URL handling
URL fields (og_image, canonical_path, path) are normalized:
- URLs starting with
http://orhttps://are rendered as-is - Relative paths are prefixed with the project's
base_url/0
This means you can store relative paths in your struct (og_image: "/images/foo.png") and they get correctly absolutized at render time.
The component dispatches base_url/0 and lang_path/2 calls to the
PageMeta struct's own module (page_meta.__struct__). No global config —
the struct itself carries the dispatch target.
Summary
Functions
Renders SEO meta tags from a PageMeta struct.
Functions
Renders SEO meta tags from a PageMeta struct.
All optional fields are read with Map.get/2, so a project's PageMeta
struct does not need to define every standard field — only the ones it uses.
Required fields (:title, :path) are accessed directly.
Hreflang alternate links are rendered when :supported_locales is set on
the page. og:locale and og:locale:alternate are rendered when :locale
is set.
Attributes
page_meta(:any) (required)