Skip to content

Publishing 0.7.0: Canonical URLs on each language's own domain

Publishing 0.7.0 is for sites that serve different languages on different domains. A post’s canonical link and og:url can now point at the domain that is home to the post’s language, instead of whichever domain the visitor used.

A canonical host per language

Your app can name a resolver function in its config:

config :phoenix_kit, :canonical_host_resolver, {MyApp.Domains, :home_host}

Publishing calls it with the page’s language and expects a host name back. With a host, the canonical URL and og:url use https:// and that host. Because the language is that domain’s default, its language prefix is removed from the path, so a German page on the German domain is linked without its /de prefix. A dialect that has its own URL segment, such as en-gb next to en-us, has its own segment removed.

When the resolver is not set, returns nil or raises, the page keeps using the domain of the request, as before. A resolver that raises logs a warning.

Hreflang in your layout

The translations list that Publishing passes to the page layout now keeps each language’s enabled flag. A host layout can use it to leave disabled languages out of its hreflang links.

Upgrading

Update the dependency. There is no migration, and nothing changes until you configure :canonical_host_resolver. Dependencies were refreshed to PhoenixKit 2.9.0.

Full release notes: Publishing 0.7.0

0.7.0 · 17 August 2026

Added

  • Canonical host resolver for multi-domain og:url/canonical (PR #42). Host apps can point a page’s canonical/og:url at the language’s home domain via config :phoenix_kit, :canonical_host_resolver, {mod, fun} (called with the page language; nil/absent/raising keeps the legacy request-host behavior). On the home host, the language’s own locale prefix is stripped — it is that domain’s default. A resolver crash logs a warning instead of degrading silently.

    The normalized :phoenix_kit_publishing_translations assign now keeps the enabled flag so host layouts can exclude legacy/disabled languages from hreflang.

Fixed

  • The stripped prefix was the base language code, not the actual URL segment (post-merge review of PR #42). strip_language_prefix/2 computed the prefix to remove via DialectMapper.extract_base/1, which is always the base code ("en"). For two enabled dialects sharing a base — an owner (e.g. en-US) and a non-owner sibling (e.g. en-GB) — the sibling’s actual public URL segment is its full lowercase code (en-gb), per LanguageHelpers.public_url_segment/1. A sibling page landing on its own resolved home host therefore kept its /en-gb/ prefix in og:url instead of having it stripped. Now resolves the segment to strip via public_url_segment/1, the same function every other public URL builder in this module uses for the owner/sibling distinction.

  • Dependency updates: phoenix_kit 2.9.0 and the transitive set it pulls (beamlab_countries 1.2.0, and others). No source changes in this package.


Publishing 0.7.0. Install or update: {:phoenix_kit_publishing, "~> 0.7"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.