PHPackages                             doublesecretagency/craft-siteswitcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. doublesecretagency/craft-siteswitcher

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

doublesecretagency/craft-siteswitcher
=====================================

Easily switch between sites on any page of your website.

3.0.1(4mo ago)6688.1k↑29.4%8[1 issues](https://github.com/doublesecretagency/craft-siteswitcher/issues)MITPHPCI passing

Since Aug 30Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/doublesecretagency/craft-siteswitcher)[ Packagist](https://packagist.org/packages/doublesecretagency/craft-siteswitcher)[ RSS](/packages/doublesecretagency-craft-siteswitcher/feed)WikiDiscussions v3-dev Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (10)Used By (0)

Site Switcher plugin for Craft CMS
==================================

[](#site-switcher-plugin-for-craft-cms)

Easily switch between sites on any page of your website.

---

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.

*\* Note: You must be using Craft's [multi-site](https://craftcms.com/features/all#multi-site) feature to access multiple languages on your website.*

---

The Twig Function
-----------------

[](#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.

Basic Usage
-----------

[](#basic-usage)

Simply use a line of code like this:

```
Español
```

That will link you to the Spanish version of the current page.

Advanced Usage
--------------

[](#advanced-usage)

If the current page is an entry, your entry might be using different slugs for each language. In that case, you can pass the `entry` object as your second parameter:

```
Español
```

That second parameter can accept any Craft element type, so you can use other elements as well! Obviously, only elements which make use of slugs (like `category` elements) will work.

```
Español
```

### Sharing site links between entries &amp; non-entries

[](#sharing-site-links-between-entries--non-entries)

Using the [null-coalescing operator](https://twig.symfony.com/doc/2.x/templates.html#other-operators), you can chain potential element types. If one isn't defined on a particular page, the next value will be used.

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

This will use the first non-null value it finds (or null if no element exists).

---

In Conclusion
-------------

[](#in-conclusion)

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

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

    English
    Español
    Français
    Deutsch

```

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.

### Dynamically looping through all sites

[](#dynamically-looping-through-all-sites)

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

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

    {% for site in craft.app.sites.getAllSites() %}
        {{ site.name }}
    {% endfor %}

```

### Checking whether a translated element exists

[](#checking-whether-a-translated-element-exists)

You can check to make sure that a translated version of that element exists before showing the link:

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

    {% for site in craft.app.sites.getAllSites() %}
        {% set siteLink = siteSwitcher(site.handle, element) %}
        {% if siteLink %}
            {{ site.name }}
        {% endif %}
    {% endfor %}

```

### Fall back to the translated homepage

[](#fall-back-to-the-translated-homepage)

Assuming your homepage is properly translated across each site, you can set the homepage as a final backstop. If the link cannot otherwise be determined, it will link to the translated homepage instead.

Simply set the optional third parameter to `true`:

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

    English
    Español
    Français
    Deutsch

```

---

Anything else?
--------------

[](#anything-else)

We've got other plugins too!

Check out the full catalog at [doublesecretagency.com/plugins](https://www.doublesecretagency.com/plugins)

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance76

Regular maintenance activity

Popularity44

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~384 days

Recently: every ~346 days

Total

8

Last Release

128d ago

Major Versions

2.3.0 → 3.0.02024-02-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/b9ec4fd6e26eb61622c4e869ab85bc19af660fbba9c0679a86c7cb39ac980c2a?d=identicon)[lindseydiloreto](/maintainers/lindseydiloreto)

---

Top Contributors

[![lindseydiloreto](https://avatars.githubusercontent.com/u/5309692?v=4)](https://github.com/lindseydiloreto "lindseydiloreto (30 commits)")[![niektenhoopen](https://avatars.githubusercontent.com/u/3450011?v=4)](https://github.com/niektenhoopen "niektenhoopen (3 commits)")[![marcusgaius](https://avatars.githubusercontent.com/u/39379513?v=4)](https://github.com/marcusgaius "marcusgaius (1 commits)")[![nweevers](https://avatars.githubusercontent.com/u/1636038?v=4)](https://github.com/nweevers "nweevers (1 commits)")

---

Tags

languagescmsswitchermultisiteCraftcraftcmscraft-pluginlocalessitesmulti-sitelanguage-switcher

### Embed Badge

![Health badge](/badges/doublesecretagency-craft-siteswitcher/health.svg)

```
[![Health](https://phpackages.com/badges/doublesecretagency-craft-siteswitcher/health.svg)](https://phpackages.com/packages/doublesecretagency-craft-siteswitcher)
```

###  Alternatives

[verbb/navigation

Create navigation menus for your site.

90683.7k17](/packages/verbb-navigation)[verbb/formie

The most user-friendly forms plugin for Craft.

101372.9k40](/packages/verbb-formie)[verbb/comments

Add comments to your site.

13753.1k](/packages/verbb-comments)[verbb/tablemaker

Create customizable and user-defined table fields.

40168.8k1](/packages/verbb-tablemaker)[supercool/tablemaker

Create customizable and user-defined table fields.

40141.7k](/packages/supercool-tablemaker)[pennebaker/craft-architect

CraftCMS plugin to generate content models from JSON/YAML data.

72148.5k5](/packages/pennebaker-craft-architect)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
