Template:Retitle: Difference between revisions

From OniGalore
Jump to navigation Jump to search
(actually it all depends on what $wgRestrictDisplayTitle is set to)
(updating doc which was long out of date; ai2_allpassive is not a redirect anymore, and this template is also used to change capitalization)
 
Line 1: Line 1:
<includeonly>{{DISPLAYTITLE:{{#if:{{NAMESPACE}}|{{NAMESPACE}}:|}}{{{title|{{{1}}}}}}}}</includeonly><noinclude>MediaWiki has a few technical limitations, which are catalogued [[wikipedia:WP:NCTR|HERE]]. One of these restrictions is that the URL for an article cannot contain spaces. As a "smart" workaround for the fact that this would lead to articles with names like "Jimmy_Carter", the MW software automatically converts the underscores in the URL to spaces in such places as the title of the article at the top of the page. In other words, MW assumes that you didn't really want that underscore to be there, so it "makes it better" by giving you spaces everywhere that it can. Sometimes this is undesired behavior.
<includeonly>{{DISPLAYTITLE:{{#if:{{NAMESPACE}}|{{NAMESPACE}}:|}}{{{title|{{{1}}}}}}}}</includeonly><noinclude>MediaWiki has a few technical limitations, which are catalogued [[wikipedia:WP:NCTR|here]]. One of these restrictions is that the URL for an article cannot contain spaces. Therefore, an article about Jimmy Carter must be placed at <nowiki>"https://en.wikipedia.org/wiki/Jimmy_Carter"</nowiki>. As a workaround for the fact that this would lead to an article with the name "Jimmy_Carter", the MW software automatically converts the underscores in the URL to spaces in the title of the article. In other words, MW assumes that you didn't really want that underscore to be there, so it "makes it better" by giving you spaces everywhere that it see underscores. It also assumes that all page titles ought to be capitalized. Sometimes these are undesired behaviors.


An example from our own wiki, look at the {{noredirect|ai2_allpassive}} page. Ignoring that this is a redirect page, notice that the page title is displayed with a space in it, even though the underscore actually belongs there. This is purely an aesthetic concern, of course, but it definitely looks weird. To fix such a page, you would put <nowiki>{{Retitle|ai2_allpassive}}</nowiki> anywhere in the markup, and voila! your underscore is in its rightful place in the title.
For instance, our wiki has numerous pages documenting BSL commands which are lowercase and actually have underscores in their names, e.g. [[ai2_allpassive]]. If that page wasn't employing this template, its title would be "Ai2 allpassive". This is purely an aesthetic concern, of course, but it definitely looks weird. To stop MW from changing the underscores and capitalization in a page's title, you can supply your own page title with <nowiki>{{Retitle|proper_page_title_here}}</nowiki> anywhere in the markup of a page with that name, and voila! your underscore will be in its rightful place in the title and the page will start with a lowercase letter.


Note that the abilities of this template are affected by the setting of <tt>$wgRestrictDisplayTitle</tt>. If it is set to true, you cannot supply a new title that does not evaluate as "equivalent" to the old one, such as "'''ai'''_allpassive". You can only change punctuation like the underscore. However, if <tt>$wgRestrictDisplayTitle</tt> is false, you can supply this template with any string and the page will be retitled as desired.
Note that this template actually allows you to do much more than preserve underscores and capitalization. Hypothetically, you can use it to completely re-title a page, but the abilities of this template are determined by the value of <tt>$wgRestrictDisplayTitle</tt>. If it is set to true, you cannot supply a new title that does not evaluate as "equivalent" to the old one, such as "'''ai'''_allpassive". You can only change capitalization and punctuation like the underscore. However, if <tt>$wgRestrictDisplayTitle</tt> is false, you can supply this template with any string and the page will be retitled as desired.


* '''Attention: Please do not [[wikipedia:WP:SUBST|Subst:]] this template. MediaWiki's article-titling abilities may improve or change in the future.'''
* '''Attention: Please do not [[wikipedia:WP:SUBST|Subst:]] this template. MediaWiki's article-titling abilities may improve or change in the future.'''


[[Category:Basic formatting templates]]</noinclude>
[[Category:Basic formatting templates]]</noinclude>

Latest revision as of 22:27, 11 May 2017

MediaWiki has a few technical limitations, which are catalogued here. One of these restrictions is that the URL for an article cannot contain spaces. Therefore, an article about Jimmy Carter must be placed at "https://en.wikipedia.org/wiki/Jimmy_Carter". As a workaround for the fact that this would lead to an article with the name "Jimmy_Carter", the MW software automatically converts the underscores in the URL to spaces in the title of the article. In other words, MW assumes that you didn't really want that underscore to be there, so it "makes it better" by giving you spaces everywhere that it see underscores. It also assumes that all page titles ought to be capitalized. Sometimes these are undesired behaviors.

For instance, our wiki has numerous pages documenting BSL commands which are lowercase and actually have underscores in their names, e.g. ai2_allpassive. If that page wasn't employing this template, its title would be "Ai2 allpassive". This is purely an aesthetic concern, of course, but it definitely looks weird. To stop MW from changing the underscores and capitalization in a page's title, you can supply your own page title with {{Retitle|proper_page_title_here}} anywhere in the markup of a page with that name, and voila! your underscore will be in its rightful place in the title and the page will start with a lowercase letter.

Note that this template actually allows you to do much more than preserve underscores and capitalization. Hypothetically, you can use it to completely re-title a page, but the abilities of this template are determined by the value of $wgRestrictDisplayTitle. If it is set to true, you cannot supply a new title that does not evaluate as "equivalent" to the old one, such as "ai_allpassive". You can only change capitalization and punctuation like the underscore. However, if $wgRestrictDisplayTitle is false, you can supply this template with any string and the page will be retitled as desired.

  • Attention: Please do not Subst: this template. MediaWiki's article-titling abilities may improve or change in the future.