I have created a template on my MediaWiki wiki which shortcuts linking to some frequently used book titles. One of the parameters controls whether the shortcut template points at my wiki or another one, via a switch case. I'd like to add another option which points to a non-wiki website, where a page for the book "Book Title" has a URL ending in "/book-title/".

To avoid having to specify alternate text or the full link in every individual case, I'd like to transform the title of the book (which is already passed to the template as a parameter) into lower case and replace spaces in the title with dashes, so it can just be inserted at the end of the URL.

Is this possible? How would you do that? I've tried searching the MediaWiki help pages for templates but haven't found anything that seems to do this.

1 Answer 1


For lower case use {{lc:...}} parser function.

For replacement in the string, use {{#replace:(string)|<nowiki> </nowiki>|-}}. Note that the space as parser function parametre has to be wrapped with <nowiki></nowiki>.

Example: {{#replace:{{lc:{{{title|}}}}}|<nowiki> </nowiki>|-}}.

(Per Guybrush McKenzie's comment) This requires enabling in LocalSettings.php the extension ParserFunctions, bundled with MediaWiki, and additionally enabling string functions of that extension:

wfLoadExtension( 'ParserFunctions' );
$wgPFEnableStringFunctions = true;
  • Thanks Alexander - this worked perfectly! Worth noting that the text parser functions are not enabled by default; perhaps you could add that to your answer too? The relevant variable is $wgPFEnableStringFunctions, which needs to be set to true in the LocalSettings config file. Commented Apr 25, 2022 at 3:09
  • OK, added this. Commented Apr 25, 2022 at 4:22
  • perfect - thank you! Commented Apr 25, 2022 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.