Hreflang Auto-Linker is a Publii plugin that manages hreflang tags across a pair of multilingual
sites. It pairs your posts, pages, and tags with their equivalents on another copy of the site
through a central mapping UI, then injects the correct <link rel="alternate" hreflang="..."> tags
into every page at build time and sets the page's <html lang="..."> attribute. Works for any two-language site pair.
- Injects
<link rel="alternate" hreflang="...">tags for posts, pages, and tags - Sets
<html lang="...">from the configured site language - Mapping UI to pair local content with partner-site content - reads the partner site database directly
- Validates all published content and logs any unmapped items
- Configurable this-site language, partner site directory, partner language, and partner base URL
Publii 0.46.0 or newer.
- Download the release ZIP.
- Publii -> Tools -> Plugins -> Install plugin -> pick the ZIP.
- Enable the plugin for the site.
Open Plugins -> Hreflang Auto-Linker -> settings icon and fill in this site's language code,
the partner site's directory name, its language code, and its base URL. Choose which site x-default points to.
Then open the mapping UI to pair each local post/page/tag with its partner-site
equivalent and save. Tags are injected on the next site render.
[!IMPORTANT] Repeat this process and configure the plugin with opposing settings from the other site as well or these links will not be bidirectional.
Feel free to fork this project or contribute a PR. Build instructions can be found in the developer readme DEV.md.
This project is licensed under the GPLv3+. See LICENSE file for details.
The rendered site output (main.js) is self-contained plain JavaScript with no
dependencies. The mapping UI bundles one library:
Bundled assets
- sql.js - MIT License - reads the partner site's SQLite database in the mapping UI. Full text: Third Party Licenses/sql.js
This project was developed by InPoint Automation Sp. z o.o. https://inpointautomation.com/
Thanks to the Publii project for the CMS and plugin API.
See CHANGELOG.md for the full version history.
