Community Central

User blog:ForestMonthZero/How to make a template redirect that will work with subst


How to make a template redirect that will work with subst

Templates can be redirected from one to another, so that you can use different names for the same template, without needing to maintain several identical templates. This works through the standard redirect function.

However, if you use substitution templates, this will not work, as a substitution operation on a redirected template link will result in the redirect being substituted in instead of the redirect's target. So in order to fix this problem, a bit of template-fu is needed:

On the redirected template page enter:

#redirect:[[Template: template destination]]
<onlyinclude>{{sub<noinclude></noinclude>st:Template: template destination}}</onlyinclude>

This will work just like a redirect for all normal functions, including normal transclusion, and it will work as one would expect if you did not know the template was redirected, to substitute in the full template on a substitution action.

-- ForestMonthZero (talk) 12:06, January 29, 2013 (UTC)

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.