There are several methods to check if a page exists. The table below describes this. But first, here is what each column in the table means:
{{PROTECTIONEXPIRY}}
[4] no no none branching doesn't exist doesn't exist doesn't exist title::exists (requires Extension:Scribunto) yes before 1.45, no after no Expensive (but one page only count once in single invocation) branching "doesn't exist" checks page existence correctly, but not the existence of the anchor "doesn't exist" linking: class="new" means non-existence yes no none seeing the page link in a style depending on existence class="extiw" checks page existence correctly, but not the existence of the anchor "exists" Special:Allpages no no none seeing the page listed or not not listed n.a. not listed Special:PrefixIndex no no none seeing the page listed or not not listed n.a. not listed (PrefixIndex is variant sensitive)
Examples:
{{#ifexist:Template:Tc|[[Template:Tc]] exists|[[Template:Tc]] does not exist}}
-> >Template:Tc exists{{#ifexist:existence a|[[existence a]] exists|[[existence a]] does not exist}}
-> existence a does not exist{{/ifeq method|Template:Tc}}
gives 1{{/ifeq method|Template:Tc|then=[[Template:Tc]] exists|else=[[Template:Tc]] does not exist}}
gives Template:Tc exists{{/ifeq method|existence b}}
gives 0{{/ifeq method|existence b|then=[[existence b]] exists|else=[[existence b]] does not exist}}
gives existence b does not exist{{/PROTECTIONEXPIRY method|Template:Tc|[[Template:Tc]] exists|[[Template:Tc]] does not exist}}
gives Template:Tc exists{{/PROTECTIONEXPIRY method|existence c|''existence c'' exists|''existence c'' does not exist}}
gives existence c does not exist{{Special:PrefixIndex/exist}} gives:
Another approach involves visiting the specified web address and checking either the content or receiving a message indicating that the page does not exist.
Branching applications[edit]An example of existence detection in practical use is:
A special case is:
If there are only a few possible pages, another option is to create them all, with extra pages using default values, and transclude them wherever necessary.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4