Page MenuHomePhabricator

magic word {{#isredirect}}
Open, LowPublicFeature

Description

Feature summary (what you would like to be able to do and where):

Create a new magic word that says if a page is a redirect, or not. That could be {{#isredirect}} with {{ISREDIRECT}} set up as a template. Output could be as follows (but comment if you think there's a more appropriate way to do this):

  • {{#isredirect}} and {{#isredirect:local}} output true or false in local language, e.g. vero for true and falso for false in Italian.
  • {{#isredirect:canonical}} outputs true or false in English.
  • {{#isredirect:boolean}} outputs 0 or 1.

These can take an additional argument:

  • {{#isredirect|some page}} outputs the redirect status of [[some page]].

It should work not only with Wikitext redirects, but also Javascript redirects (which have different syntax), and Vue redirects (after T401158: Enable redirects for Vue components).

Benefits

This would be mainly useful in system messages, e.g. redirects say that they are "articles," when they are not articles, but redirects to articles.

image.png (321×664 px, 47 KB)

This could be fixed with a switch in [[MediaWiki:nstab-main]].

It could also be useful in bot-generated reports.

I could be used as an IF function and a second magic word, {{#redirecttarget}} to pull that page's target. So, T404410: Create a new magic word that pulls a redirect's target page.

Event Timeline

Note that Scribunto can already tell if a page is a redirect. It might make sense for core to be able to too, though.

Bugreporter2 renamed this task from magic word {{ISREDIRECT}} to magic word {{#isredirect}}.Sep 11 2025, 3:20 AM
Bugreporter2 updated the task description. (Show Details)

Note that Scribunto can already tell if a page is a redirect. It might make sense for core to be able to too, though.

The argument that it should be in core is that Lua is an extension, which may not be enabled on all wikis. It's basically the logic used in T328254: Parser function for content model {{#contentmodel:}}, which @cscott agrees with.

That's not exactly my logic. Scribunto is the standard template system for mediawiki. For most purposes it is preferred to template logic. If there's a use in standard system message distributed with base mediawiki, then it might make sense for it to be in core.

It would be more convenient if {{#isredirect}} is an alias of {{#isredirect:boolean}} instead of an alias of {{#isredirect:local}}, since the main use case would be inside an {{#if:}} statement and {{#if:{{#isredirect}}||}} feels more natural than {{#ifeq:{{#isredirect}}|true||}}.

The latter would also create unnecessary confusion for people copying a template into a wiki using a different language since #isredirect would not need to be translated whereas true would need to.