Help talk:Substitution

message: I don't understand this help page and I doubt that anyone else without a lot of experience in Wiki coding would either. Can someone explain the reasons for substitution, other than the expanded text, to me in plain English? Also, as a general comment, I have to say I find filling in the gaps in the expanded text difficult, laborious and not at all user-friendly. Thanks.Grant65 | Talk 07:48, 11 January 2007 (UTC)
replies: text: One could add  --Nopetro 17:08, 16 June 2007 (UTC)
replies: text: See "Benefits of substitution" on Wikipedia:Template substitution.  Dar-Ape 19:21, 28 November 2007 (UTC)
thread_title: Why substitute?

message: I am trying to build a template that includes the title of the page that is using the template.  Simple enough, use:

However, I plan to transclude the template using page onto other pages and want a link back to the template using page automatically created. So I did the following

But, this substituted the title of the template page and not the template using page.  Not what I wanted.  The solution seemed easy enough, surround the the code with includeonly tags so that the substitution occurs on the template using page rather than on the template page its self:

The result of that, however, is to literally display "" on the template using page, not the desired result.
I've tried all sorts of other combinations, including only the "subst:", substituting the substitution, including only the substitution of the substitution, including only the included only substitution of the substitution, this thing -->  (which wouldn't work anyways because the link back would be to a page that doesn't necessarily exist).
Advice? Suggestions? Ideas?
192.75.172.1 (talk) 19:11, 28 November 2009 (UTC)
replies: text: I think I was trying for much the same effect. Try {{subst: FULLPAGENAME}} , for a working example (for now) see User:Unomi/hex. un☯mi 10:51, 19 August 2010 (UTC)
thread_title:  Template with substitution and subsequent transclusion 

message: Like much  of help-space this is poorly written, and uses examples from Meta that don't exist here.  Any wiki clarificaton would be a good thing. Rich Farmbrough, 19:49, 19 June 2010 (UTC)
thread_title: Clarify

message: I can only emphatically agree with the criticism directed at the current documentation. 
I am trying to get a substitution template to evaluate prior to being substituted in, and I am not able to parse to the documentation enough to figure out how to get that done. 
If someone is able to tell me how to achieve that I would be very much in their debt, in return I shall update this page :) Please see here, feel free to edit it for effect. The result of    should be only the result of the evaluation, not having the logic embedded on the page, Many thanks in advance, un☯mi  08:47, 19 August 2010 (UTC)
replies: text: It seems you found it?--Patrick (talk) 11:54, 19 August 2010 (UTC)
replies: text: I managed to find a signature subst template which implements it. But it seems like something so useful that it could do with being presented here, or at least more clearly if it already is :p un☯mi 11:56, 19 August 2010 (UTC)

text: By the way, do we have any hexadecimal helpers? I see that :Template:Digit uses a decimal rendition of base 16 . un☯mi 11:58, 19 August 2010 (UTC)
replies: text: Does  do what you want? --Redrose64 (talk) 12:35, 19 August 2010 (UTC)
replies: text: Lovely! Thanks! :) un☯mi 12:42, 19 August 2010 (UTC)
thread_title:  utterly demotivating 

message: Could someone who understands safesubst: please rewrite that section of the page? It is utterly incomprehensible at the moment. It does not make it clear what safesubst: is even for, let alone how it works or how to use it. — This, that, and the other (talk) 00:55, 30 December 2010 (UTC)
replies: text: I hope the section as it now stands works better than the old one.--Kotniski (talk) 11:56, 26 February 2011 (UTC)
thread_title:  safesubst section does not make sense 

message: The page says "Use subst: in place of plain subst:. The includeonly tags break up the substitution syntax when the template is saved, but those tags will be stripped away when it is later substituted, allowing the inner substitution to take effect." I've tried this and it doesn't work. It made  appear as plain text. McLerristarr | Mclay1 09:14, 25 February 2011 (UTC)
replies: text: Are you sure? I've just tried it (at User:Kotniski/Sandbox and then subst'ing at User:Kotniski/1) and it seems to work. --Kotniski (talk) 11:13, 25 February 2011 (UTC)
replies: text: I tried it on User:Mclay1/Sandpit and User:Mclay1/Sandpit 2. McLerristarr | Mclay1 04:50, 26 February 2011 (UTC)
replies: text: So it should work, as long as you do the "subst:" in Sandpit 2. (It won't work on transclusion, as explained elsewhere on the page, although you could use "safesubst:" in place of "subst:" in Sandpit to give the same result at Sandpit 2 even on transclusion.)--Kotniski (talk) 11:59, 26 February 2011 (UTC)
replies: text:  McLerristarr | Mclay1 14:49, 28 February 2011 (UTC)
thread_title:  includeonly 

message: To me the explanation of safesubst:, while it may be right, it isn't very helpful.  It uses jargon and packs it in so tight that I cannot work out what it is saying or meaning.  That being the case if there is no other means to explain it, then we should look to examples.  If we could look to clearly state when it should be used, and what makes it "safe" that would be great. 112.213.156.24 (talk) 12:44, 12 April 2011 (UTC)
thread_title:  Safesubst: is jargon loaded 

message: I was never able to get subst:PAGENAME to work. Then I found this:
http://www.mediawiki.org/wiki/Help:Templates#Usage
Which mentions using subst::PAGENAME with two colons instead of one. That worked for me, and is apparently undocumented on any page (wikipedia, mediawiki, wikimedia, or metawiki) that is dedicated to documenting substitution. Is it just me, or is having documentation spread out across 4 different sites a contributing factor for poor documentation in general, and of substitution in particular? 
Badon (talk) 19:08, 12 September 2011 (UTC)
replies: text: It's an old question but for interested readers,  works on "Template:PAGENAME" while  works on the mainspace page "PAGENAME". It's like normal transclusion where  transcludes a mainspace page instead of a template. It's mentioned in Help:Substitution#Syntax and was also there in 2011. PrimeHunter (talk) 15:34, 28 September 2022 (UTC)
thread_title:  subst:PAGENAME versus subst::PAGENAME 

message: I don't understand the limitation, in particular, the second sentence of Help:Substitution#Limitation.  I'd like to use subst inside a ref on  or  to get 29 January 2016 or 29 January 2016
Reading it, I have no idea why this limitation exists  (is it a feature, bug or both?), and what  
 will do.  It does this outside of a ref: content of the reference... Oh I think I get it, now that I try to explain how I don't get it. 
I guess I can do substitution inside the "content of the reference" , e.g.
I guess   will expand the templates and then place that expanded text within ref tags.  Result: 29 January 2016 or 29 January 2016 .
OK, so how to clarify?  The example given needs to use subst.  I gave it a try.  Glad User:Carfois added it a year ago.  --Elvey(t•c) 01:12, 29 January 2016 (UTC)
thread_title:  Clarify [[Help:Substitution#Limitation]] 

message: Could someone who understands this material in depth, and who has good technical writing skills, please overhaul everything from the "Recursive substitution" section though "Limitation" (aside from "Documenting substitution", which is clear)?
I can only make sense of about 60% of that material, despite being intelligent, a systems and network administrator and Web coder since the mid-90s, a Wikipedian for over 10 years, and a template-editor almost since that bit was introduced (and an editor of templates the whole time).  It's basically written like a  page from the pre-GNU days, a crib sheet for people who are already experts at what the documentation is about.
It needs a table of common uses cases and example code and output that show entire templates, not fragments.  I can't even tell if there's a way to have a template work fine if transcluded, work fine if subst'd, and subst "cleanly" and recursively (i.e. leave plan content behind with no  stuff in the page for the next editor) if it is subst'd. The doc talks about all of these aspects in different places and in inconsistent terms, without ever just answering the question directly, even though it must be a common one.
Also trying to figure out if there's a way to get templates to subst themselves automatically (I know can have them save with subst: in them so they'll at least do it the next time the section or the whole page is saved, but it would be advantageous for them to be forcibly substituted sometimes, without having to throw up melodramatic red warnings.  If not, is there a bug open to fix it? I can't check; I have never been able to login to PHabricator; it always throws an LDAP error at me, and of course I can report this bug because I can't login). 
For my work, the immediate need is to ensure that single-source templates are subst'd, cleanly.  My rede on this is that the best we can do is document that they should be subst'd, and include code such that, if they are not, they include subst code when saved, so that the next time the page or section is saved it will be subst'd. (We could include a huge red warning instead, but that seems overkill for something that trivial).  — SMcCandlish ☺ ☏ ¢ ≽ʌⱷ҅ᴥⱷʌ≼  11:28, 21 March 2016 (UTC)
replies: text: If substitution could be forced, we'd set this up for templates like  etc. - but we can't. --Redrose64 (talk) 17:55, 22 March 2016 (UTC)
replies: text: Was hoping there was some "secret trick".  — SMcCandlish ☺ ☏ ¢ ≽ʌⱷ҅ᴥⱷʌ≼  20:33, 22 March 2016 (UTC)
thread_title:  Much of this is unclear and needs to be reworked by a technical writer 

message: #tag:ref doesn't seem to support ref names.
Example:

works all right:
But I want to put the ref name as nscb. I tested using #tag:ref name="nscb" instead:

but it adds ref name tags at the start and end of the citation:
What is the code to add only the ref name at the start and the closing </ref> tag only at the end of the citation? Thanks. Sanglahi86 (talk) 10:34, 17 October 2016 (UTC)
replies: text: Looking at Help:Magic words#Formatting, the syntax should be...

...with the name moved to the end. A quick test: there's a reference defined here  and used again here . -- John of Reading (talk) 11:13, 17 October 2016 (UTC)
replies: text:  Thank you very much for the information. Sanglahi86 (talk) 13:07, 17 October 2016 (UTC)
thread_title:  <code>#tag:ref</code> not supporting ref names? 

message: (If this is not the right forum in which to post a question about writing a subst'ed conditional template, please point me to the right place.)
I'm a new template writer, and when I subst a template I thought that one of the benefits was that all the conditionals and magic words and other such things get removed, leaving whatever they generate: plain text, wikilinks, and so on.  But I'm transcluding my new template and it's leaving some pretty ugly stuff in the expanded wikicode.  The rendering on the page looks just fine, it's just the wikicode that is ugly, but I thought that stuff was supposed to all just disappear.
Template:x2 review help is a template designed for user talk pages, and generates an invitation to join our translation project.  It's mostly boilerplate that just gets plonked onto the user talk page, but there are some params to conditionally generate text, like what language we're talking about, and a few others. It also generates the Section title, and even *that* has an #ifexpr in it; very ugly.
Am I doing something wrong? Is there a way to just generate plain text, and get rid of all the ugly conditional code?  An example of the template in use is available at User:Mathglot/sandbox/test Farsi x2 review. Feel free to alter that page to run further tests if needed.  I'd love to know what I'm doing wrong.
Thanks in advance! Mathglot (talk) 03:57, 31 May 2017 (UTC)
replies: text: Hey! It looks like you're after recursive substitution. I recently made an edit to a similar template for almost the same thing. If you give me a few minutes, I'll make an edit to your template that should sort things out. :) TheDragonFire (talk) 06:04, 31 May 2017 (UTC)
replies: text:  Wow, I never thought of that, good catch!  Plus I'm learning something.  Very kind of you to fix the template for me, while you're doing that, I'll read up on recursive substitution.  Thanks again!  Mathglot (talk) 06:09, 31 May 2017 (UTC)
replies: text:  I see you've made an edit; wasn't sure if you were done or not; I notice an "unrecognized '{'"  in the test in my sandbox:  #Test 2.  I might be able to locate it, or are you still busy with the template?  Mathglot (talk) 06:40, 31 May 2017 (UTC)

text:  Yeah, I've partially reverted my changes as something is breaking with the article section. Feel free to keep editing the template, I'll fix it to fully use recursive substitution when I figure out what I'm doing wrong. TheDragonFire (talk) 06:46, 31 May 2017 (UTC)
replies: text:  I can't thank you enough for what you've already done.  Way more complex than I thought, and will have to read through it carefully to try to understand.  Almost all the cruft is gone, *especially* the junk in the section title, which was really important.  I can certainly live with it like this, in case it ends up being too much of a time-waster to track down the last bit of it, and I thank you again. Mathglot (talk) 06:48, 31 May 2017 (UTC)
thread_title:  Why is Subst leaving conditional cruft after transclusion 

message: Can someone just tell me what I actually need to know about subst in order to not fuck up when I use it? Something like When you see subst:, it means the template is going to substitute one thing for another for you. Just copy the whole damn thing and insert it where it belongs. You don't have to make any changes. Or what? I don't have the technical knowledge to be able to understand this page. —valereee (talk) 13:13, 5 September 2020 (UTC)
replies: text: This stems from a conversation on my talk page. I responded there before noticing this message. Graham87 13:37, 5 September 2020 (UTC)
thread_title:  TLDR version for dummies? 

message: Is there a way to easily replace  with  in all pages? WP:AWB can do that, but it's quite complicated for what's basically just one bit of information, especially since it's something we want to encourage. ◅ Sebastian 08:59, 5 November 2020 (UTC)
replies: text: If the consensus is that a particular template should always be substituted in future, then see Template:Always substitute. If you add  to the template documentation, then a bot will make sure they get cleaned up. -- John of Reading (talk) 09:57, 5 November 2020 (UTC)
replies: text:  Cool, thanks! That's a very sensible solution. ◅ Sebastian 16:07, 5 November 2020 (UTC)
replies: text:  What about adding alwayssubst=yes to the template documentation in TemplateData?--BoldLuis (talk) 14:49, 16 November 2022 (UTC)
thread_title:  Substituting templates after they already have been transcluded 

message: There are quite a few cases of failed substitution within references that need to be cleaned up, found with . Letcord (talk) 18:32, 2 April 2022 (UTC)
thread_title:  Cleanup 

message: Why not just have a tag <nosubst> whose content is removed by subst:, so it is only displayed if the template is transcluded? (a functionality somewhat similar to <noinclude> and <includeonly>)
This way, you can display a big ugly warning to the user who misses the subst:, add the page to a special category or whatever you want. Much less intrusive than the other proposed changes.
From phab:T4003 BoldLuis (talk) 14:47, 16 November 2022 (UTC)
replies: text: You already brought this up at Help talk:Template#.3Cnosubst.3E - please observe WP:MULTI. --Redrose64 🌹 (talk) 17:17, 16 November 2022 (UTC)
thread_title:  <nosubst> 

message: has been deprecated since 2010 (pending various conditions, which were never met), but limps along anyway. Worse, the community deprecated all inline parenthetical referencing in 2022, but  is dependent on , which is a form of (partial) inline parenthetical referencing.  We need a way to cleanly subst  into its constituent  parts, so that further replacement work can be done, e.g. with  or some other solution.
I've copied the current code of  into , and done the same with its substemplates, and changed the sandbox code of all of them to refer to the sandbox versions of the subtemplates. This could use attention from someone already skilled in the pitfalls of getting complex templates to substitute cleanly without leaving behind conditional garbage and other problems.  — SMcCandlish ☏ ¢ 😼  17:08, 22 January 2024 (UTC)
thread_title:  A complex safesubst'ing job