Search by

studio-variable / kirby-redirects

isUnknown

Redirects managed from the Panel with a structure field, and a toggle in the Rename dialog to redirect a page's old address

Package info

forge.studio-variable.com/studio-variable/kirby-redirects.git

Homepage

Issues

Type:kirby-plugin

pkg:composer/studio-variable/kirby-redirects

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

v0.2.0 2026-12-01 07:45 UTC

This package is auto-updated.

Last update: 2026-12-01 07:45:11 UTC


README

Redirects managed from the Panel: a structure field lists old addresses and where they lead, and renaming a page can redirect its old address to the new one.

The redirects field in the Panel

Requirements • Installation • Usage • Renaming a page • How addresses are matched • Customizing • Configuration • Translations • License

Requirements

  • Kirby 5 or 6
  • PHP 8.2+

Installation

Composer (recommended)

composer require studio-variable/kirby-redirects

Manual installation

Download the repository and copy it to site/plugins/redirects.

Usage

The plugin provides three blueprints. Use whichever fits the site:

BlueprintUse it…
pages/redirectsas is: create a page with the redirects template at the top level of the site
tabs/redirectsas a tab of the site or of any page: redirects: tabs/redirects
fields/redirectsas a single field: redirects: fields/redirects

The tab holds an info text and the field. The field must be named redirects.

Each rule has:

  • an old address: a path on this site, or a full URL pasted as is (only its path is kept);
  • a target: a page of the site, picked in the page tree, or an external URL;
  • a type: permanent (301), the default, or temporary (302).

Saving is refused, as for any invalid field, when an old address is empty or already answers with a page.

A page target is stored by its UUID: if the page is moved or renamed, the redirect follows. A rule pointing to a page also covers its subpages: with /old-texts → Texts, /old-texts/1998 leads to /texts/1998.

Where rules are read

Rules are read from the redirects field of the first top-level page using the redirects template, or of the site when there is none. Set the page option to read them from another page.

To link it from a custom Panel menu, point an entry to the page (pages/redirects) or to the tab (site?tab=redirects).

Renaming a page

As soon as the slug is edited in the Rename dialog of a published page, a Create a redirect toggle appears, on by default: Redirect the old URL to the new one. Its help links to the place in the Panel where rules are managed (the redirects tab of the page or site holding them).

When the slug changes with the toggle on, a 301 rule from the old path to the page is added, and any rule from the new path is removed, since the page now answers there. Drafts have no public address, so the toggle is not shown for them.

The dialog is Kirby's own: the plugin only adds the toggle, and a small component extending k-form-dialog shows it once the slug differs from the current one.

The Rename dialog with the redirect toggle

Set changeSlug to false to remove the toggle.

How addresses are matched

Addresses are compared without the domain, query string, fragment and trailing slash, case insensitively and URL-decoded: https://old.example.org/News/Archive-2019/?page=2 matches /news/archive-2019.

A rule only applies when no page answers at its address. The route is registered after all plugins are loaded, so routes from the site's config and from other plugins come first. Rules are cached, and the cache is cleared whenever a page or the site is saved.

The field is not translatable: on a multilingual site, rules are shared by all languages and match paths as requested, language prefix included.

Customizing

Extend the blueprints and override what you need, like any Kirby blueprint. For example, a site tab with its own explanation:

tabs:
  redirects:
    extends: tabs/redirects
    label: Old addresses
    fields:
      redirectsInfo:
        text: Links to the previous site (2012–2024) still circulate. Add a rule when one of them leads nowhere.

To replace the page blueprint entirely, create site/blueprints/pages/redirects.yml and include fields/redirects or tabs/redirects in it.

Configuration

KeyTypeDefaultDescription
studio-variable.redirects.fieldstring'redirects'Name of the field holding the rules
studio-variable.redirects.templatestring'redirects'Template of the page holding the rules
studio-variable.redirects.pagestring\|nullnullID or UUID of the page holding the rules; null looks for the template, then falls back to the site
studio-variable.redirects.changeSlugbooltrueAdds the redirect toggle to the Rename dialog
studio-variable.redirects.cachebooltrueCaches the rules

Translations

English and French are included. Keys start with studio-variable.redirects.; see src/extensions/translations.php.

License

MIT License © 2026 Studio Variable