This plugin provides an easy way to switch between sites on your website. Regardless of which page you are currently on, you will be linked to the same page in its parallel site.

The Twig Function

siteSwitcher(siteHandle, element = null)
  • siteHandle - The handle of your site (ie: english).
  • element - (optional) If the current page is an entry (or another element type), you can pass that element in as the second parameter. This ensures that any translated slugs are properly used.

Returns a URL which links to the alternate-site version of the current page. If the siteHandle or element is invalid, false will be returned instead.

How to Use

A simple piece of code like this one will work great across 99% of sites:

{% set element = (category ?? entry ?? null) %}

    <li><a href="{{ siteSwitcher('english', element) }}">English</a></li>
    <li><a href="{{ siteSwitcher('spanish', element) }}">Español</a></li>
    <li><a href="{{ siteSwitcher('french', element) }}">Français</a></li>
    <li><a href="{{ siteSwitcher('german', element) }}">Deutsch</a></li>

You can use this code in an include, and share it across your entire website. If the page is an entry page, it will use the localized version of that entry's slug. Otherwise, it will simply retain the same URI for each link.

If you want to dynamically loop through each of your sites, try this instead:

{% set element = (category ?? entry ?? null) %}

    {% for site in %}
        <li><a href="{{ siteSwitcher(site.handle, element) }}">{{ }}</a></li>
    {% endfor %}
Installation Instructions

To install this plugin, copy the command above to your terminal.

Active Installs
Craft 3, Craft 4, Craft 5
Last release
February 21, 2024
Activity (30 days)
Closed Issues
Open Issues
Merged PRs
Open PRs