Template talk:Find substed
Handling redirects
[edit]The template currently does not follow redirects, and m thinking about whether to add redirect handling, but can't decide if it's a good idea or not. Or maybe only follow redirects based on a param, maybe |follow=yes
, or something. Case to think about: Template:Edit summary personal. This is a redirect, so the generated link from this invocation won't find anything:
{{fsubst|Edit summary personal|ns=Template}}
→ https://en.wikipedia.org/w/index.php?search=User+talk%3A+insource%3A%22Edit+summary+personal%22+insource%3A%2F%5C%3C%21--+%2ATemplate%3A%5BeE%5Ddit+summary+personal+%2A--%3E%2F&title=Special%3ASearch&profile=default&fulltext=1
But if we resolve the redirect with {{#invoke:redirect|main|Template:Edit summary personal}}
→ Template:Uw-bes2
and then plug that in instead, we get a link that produces results:
{{fsubst|Uw-bes2|ns=Template}}
→ https://en.wikipedia.org/w/index.php?search=User+talk%3A+insource%3A%22Uw-bes2%22+insource%3A%2F%5C%3C%21--+%2ATemplate%3A%5BuU%5Dw-bes2+%2A--%3E%2F&title=Special%3ASearch&profile=default&fulltext=1
(Another case is Template:Edit summary personal 3 → {{uw-bes3}}.) And it would be simple enough to follow the redirect in the code, to find substitutions of the template under the actual template name. Maybe it should be under parametric control, whether to follow, yes or no. Mathglot (talk) 01:36, 29 March 2025 (UTC)
- Ha! should've checked my assumptions at the door. Although there are examples of pure redirects which were never the previous name of the template and therefore return no results, that top link is not one of them. So, if you click the top link, you actually do get some results from many years ago, although the bottom link returns a lot more, from after it was moved to the current name. Not sure this changes the calculus of the basic issue at hand, however. I think probably we should follow redirects by default, and add a param
|nofollow=yes
to turn it off. Mathglot (talk) 01:50, 29 March 2025 (UTC)
Enhancement for templates that don't subst their own name
[edit]As mentioned in this discussion (diff), we could check whether the template substs its own name, and by default, return the empty string instead of a search link if it does not. This could be used as a condition that {{Tfd links2}} could test for, and not emit the link. We may also want to add a new param, |force=y
, which would force it to emit a link even if it returns zero results (i.e., skip the check). Mathglot (talk) 22:11, 30 March 2025 (UTC)