水加日念什么| 28岁属什么生肖| 生化全项包括什么| 小丑代表什么生肖| 用什么方法止咳| 水泡型脚气用什么药| 鸽子喜欢吃什么食物| 浙江有什么城市| 粤语点解什么意思| 啦啦是什么意思| 理工科是什么意思| 飞机什么东西不能带| 步步为营是什么意思| 宫颈肥大是什么原因造成的| 小孩病毒性感冒吃什么药效果好| 孕激素高会有什么影响| 菠萝蜜什么季节最好吃| 一什么水壶| 下岗是什么意思| 今天开什么| 地藏经适合什么人念| 散文是什么意思| fnc是什么意思| 美育是什么| 天蝎座和什么星座不合| 如如不动是什么意思| 丑时五行属什么| 这是什么动物| gap是什么档次的牌子| 5月4号是什么星座| 家里为什么有蟑螂| 马的贵人是什么生肖| 红红的眼睛是什么生肖| 提辖相当于现在什么官| 两票制指的是什么| 什么地工作| 心肝血虚吃什么中成药| 造孽是什么意思| 静脉血栓吃什么药| 狗与什么属相相冲| 梦见做棺材是什么意思| 自由奔放是什么生肖| 年底是什么时候| ggo是什么意思| 什么军官可以随身配枪| 3月19日什么星座| 全身骨头疼是什么原因| 什么是三焦| 男人梦见老鼠什么征兆| 3月29日是什么星座| 禄存是什么意思| 早上起来口干口苦是什么原因| 孙膑原名叫什么| 蛇是什么动物| 静脉血栓吃什么药| 八九不离十是什么意思| 嗜酸性肉芽肿是什么病| 一个至一个秦是什么字| 冷宫是什么意思| 金青什么字| 为什么会长花斑癣| 头发为什么长不长| 麻疹的症状是什么| 王加呈念什么| 九华山在什么地方| 斑鸠吃什么| 经常头晕是什么原因| 紫癜是什么症状| 小孩子手脱皮是什么原因引起的| 回奶吃什么快最有效的| 腮腺炎吃什么消炎药| 小肚子鼓鼓的什么原因| pashmina是什么面料| 一只什么| 震颤是什么症状| 女人左眼跳是什么意思| 纳米是什么东西| 感冒引起的喉咙痛吃什么药| 静脉曲张不治疗会有什么后果| 牙根出血是什么原因| 第一磨牙什么时候换| 不什么而同| 弯弯的什么| 虾虎鱼吃什么| 脑缺血灶吃什么药| tin是什么| fps是什么意思| 上火嗓子疼吃什么药| 淳朴是什么意思| 11月22是什么星座| 雷贝拉唑钠肠溶片什么时候吃| 衣钵是什么意思| 突然膝盖疼是什么原因| 天才是指什么生肖| npv是什么病毒| 胃不好的人吃什么养胃| 包皮是什么意思| 百香果什么时候开花结果| 韭菜什么人不能吃| 阿碧的居所叫什么名字| 减肥能吃什么水果| 10月19日什么星座| burgundy是什么颜色| 做梦孩子死了什么预兆| 经常喝咖啡有什么好处和坏处| 床上放什么可以驱蟑螂| 血糖高喝酒有什么影响| 扦脚是什么意思| 四大才子中状元是什么生肖| 抑郁症是什么病| 月经前一周是什么期| 遗传物质是什么| 七夕送老婆什么| 床上出现蜈蚣什么原因| 经常梦遗是什么原因| 谢邀什么意思| 狗狗咳嗽吃什么药好得快| 碘化银什么颜色| 血压高什么症状| 咳嗽消炎药吃什么好| 检查肾功能挂什么科| 妊娠期是什么意思| 在编是什么意思| 什么姿势最深| 吃什么可以软化血管| 鸟屎掉脸上有什么预兆| 高密度脂蛋白低是什么原因| 虫至念什么| 蔬菜沙拉都放什么菜| 糠是什么东西| 艺高胆大是什么生肖| 职称有什么用| 血糖和血脂有什么区别| ggo是什么意思| 嘴角边长痘痘是什么原因| 迪奥是什么| 复方是什么意思| 低血糖有什么症状表现| 什么哲理| 胃炎吃什么中药| 啫啫煲为什么念jue| 打完狂犬疫苗有什么不良反应| 颅骨早闭合有什么症状| 减肥什么方法最快最有效| 芳华是什么意思| 久站腰疼是什么原因| oof是什么意思| 虎与什么生肖相合| 急性心力衰竭的急救措施是什么| 整装待发是什么意思| 完美收官什么意思| 付字五行属什么| 什么叫牙周炎| 鳄鱼属于什么动物| 郑州有什么好玩的景点| 脑梗吃什么最好| 薄荷长什么样| 黄瓜与什么食物相克| 当兵有什么好处| 孕妇做春梦是什么意思| 风湿病是什么引起的| 孙耀威为什么被雪藏| 脾虚喝什么泡水比较好| 老出汗是什么原因| 医学pr是什么意思| 黄芪什么味道| 办理健康证需要什么| 3e是什么意思| 曹操属什么| 什么是集合| 芒果有什么营养| 1985年什么命| emo是什么意思| 厚颜无耻是什么意思| 三点水加累读什么| 结膜水肿用什么眼药水| 牙疼去医院挂什么科| 下头是什么意思| 碳酸钠是什么东西| 夏季感冒吃什么药| 月老叫什么名字| 爱马仕配货是什么意思| 胃痉挛有什么症状表现| 5月20日什么星座| 睡觉憋气是什么原因引起的| 荔枝对身体有什么好处| 锲而不舍下一句是什么| hib疫苗是什么意思| 儿童发烧挂什么科| 肝硬化吃什么水果好| 腹股沟淋巴结肿大挂什么科| 腿上血栓是什么症状| 过敏性鼻炎用什么药效果最好| 吃什么促进腺样体萎缩| 氢化油是什么东西| 刺梨有什么功效| 接亲是什么意思| 类风湿性关节炎用什么药| 鲤鱼打挺是什么意思| 三月三日是什么星座| 孕妇吃海带有什么好处| 属虎生什么属相宝宝好| 什么样的人容易孕酮低| 什么是飞机杯| 阴道真菌感染用什么药| 狗是什么生肖| 丝瓜不能和什么食物一起吃| 局长是什么级别干部| 术语是什么意思| 夏天适合种什么菜| 茼蒿和什么相克| 一纸空文是什么意思| 眼睛疼是什么原因| 笋壳鱼是什么鱼| 口痰多是什么原因| 多云是什么意思| 恙虫是什么虫| 真维斯属于什么档次| 胶质瘤是什么病| 肛门挂什么科| 夏天不出汗是什么原因| 什么叫卒中| 看牙挂什么科| 灰指甲用什么药效果好| 老是吐是什么原因| 一边脸大一边脸小是什么原因| 乐什么什么什么成语| 宾字五行属什么| 年夜饭吃什么| 副县长什么级别| 古尔丹代价是什么| 剑齿虎为什么会灭绝| 十二生肖排第七是什么生肖| 慢性盆腔炎吃什么药| 广字五行属什么| 疱疹用什么药好得快| 儿童干咳吃什么药| 序五行属什么| 盆腔积液是什么原因造成的| 动手术后吃什么对伤口恢复比较快| 胃窦炎吃什么药效果最好| 大唐集团什么级别| 1985是什么年| 心什么| 卫生巾有什么用| 法老是什么意思| 手串13颗代表什么意思| 口干口苦吃什么药好| 酸奶坏了是什么味道| 脾虚吃什么| 咿呀咿呀哟是什么歌| 父亲b型血母亲o型血孩子什么血型| 运动员为什么吃香蕉| 祭奠用什么花| 痰湿中阻吃什么中成药| 3月7号是什么星座| 甲功能5项检查是查的什么| 乾卦代表什么| 九个月的宝宝吃什么辅食食谱| 乌龟喜欢吃什么| 脾胃虚寒吃什么药好| 孕妇吃梨有什么好处| 希尔福是什么药| 亡羊补牢的亡是什么意思| 百度Jump to content

From Wikipedia, the free encyclopedia
百度 此外,追究引发雾霾天气的根本原因是国家的经济发展政策不合理。

Templates are a very powerful feature of MediaWiki, but can be confusing to new users and even experienced users can have difficulty making sense of the more complex ones. Templates should therefore be accompanied by documentation to improve usability.

Template documentation should explain what a template does and how to use it. It should be simple enough that a user without complete knowledge of the intricacies of template syntax—which includes many experienced contributors who focus their attention elsewhere—can use it correctly. This is especially true in the case of very widely used templates.

Editors should defer to official policies or guidelines when template documentation pages are inconsistent with established community standards and principles. Editors should also avoid "quoting" template documentation pages as though they are policy—including this how-to guide. Template documentation pages can be written without much—if any—debate, as opposed to Wikipedia policies that have been thoroughly vetted by the community (see WP:Local consensus for details).

What to include

Template documentation should cover:

  • The basic purpose of the template: what it does and if it is not immediately obvious, why it needs to be done. If there are other templates with similar names or purposes, it's a good idea to mention those, in order to reduce the chance of the wrong one being used. Include important limitations, such as the lack of {{Navbox visibility}} on the Mobile web site, if a template should only be used for certain countries or time periods, or other things that editors need to know before choosing to use the template.
  • The parameters of the template: whether they are numbered, named or optional, and if so, what the default values are and what effect they have. If a parameter can take only a limited set of values or is constrained in any way, for example, if it can only use "yes", "no", or a number, this should be clearly explained.
  • Usage examples: specify the exact wikitext that should be used and the result that it produces. The wikitext can be enclosed in a <code>...</code> container, to make it clear and easy to copy, like this. If the template can be used in several ways, with or without optional parameters, for example, provide a range of examples. A good way to do so is to transclude the template itself into the documentation a few times (i.e., use live examples), with different parameters each time and list the parameters used in each case. With {{demo}} this can be done without putting the template call twice in the wikitext.
  • TemplateData tags: See Wikipedia:TemplateData/Tutorial.
  • Related templates: if the template is one of a series of templates, include links to these – in particular, ensure that every template in the series is linked from each of the others, as this makes navigation easier. (A separate navigation template may be useful for this purpose, e.g., {{Protection templates}}).
  • Categories where applicable (InterWikimedia links should be listed at Wikidata – more information at Wikipedia:Wikidata). Like the documentation, categories must be listed within a <noinclude>...</noinclude> container on a template, or within <includeonly>{{Sandbox other||...}}</includeonly> tags if placed on a documentation page. Many template categories are available, see: Category:Wikipedia templates to browse through them.

The English Wikipedia is a source of templates for hundreds of other Wikipedias and sister projects. Often, templates are fully self-contained, so the process is easy: The contents are simply copied to a new template page at the other wiki, and everything works. However, on more complex templates, the template may invoke a module, transclude other templates, only work if paired with a separate template, or need particular CSS or JavaScript code to work. In these cases, it is helpful to include a brief list of templates or other code that this one requires, at the end of the documentation.

Where to place it

When viewing the rendered template page itself (as opposed to its wikicode), what is usually visible right under the title is the rendered template itself, followed by a separate section to display the template's rendered documentation, followed by the categories to which the template belongs. Categories and documentation of any sort on a template page (including TemplateData) should always be enclosed by noinclude tags, so that they do not show up when the template is used on another page.

The editable wikicode for the template's documentation is often placed on a separate subpage of the template itself, which is then transcluded at the end of the template page. This separates the often complex template code from the documentation, making the documentation easier to edit and reducing the number of accidental editing errors in the template code. It also allows templates to be protected where necessary, limiting editing access to important templates' code while allowing anyone to edit those templates' documentation. This method is sometimes referred to as the "template-doc page pattern".

How to create a documentation subpage

Put documentation in the template

You must put {{documentation}} when creating (publishing) a template. Then a documentation page is created with [view] [edit] [history] [purge] links. You can create and edit the template documentation clicking in this pane [edit] link.

Template documentation subpages using {{documentation}} are named and formatted using the following general pattern, for consistency.

Suppose your template is named Template:X. Edit the template and append the following at the end of the template code, or use {{subst:doc-code}}:

[--last line of your template code--]<noinclude>
{{Documentation}}
<!-- Add categories to the /doc subpage and interwikis in Wikidata, not here! -->
</noinclude>

This will transclude {{documentation}} at the bottom of the template page.

Important: Make sure the opening <noinclude> begins immediately after the last character of the template code or text and not on a new line, nor with any intervening spaces. Otherwise, extra space will be inserted below the template when it is used, which is usually not wanted.

If the template is already protected, ask an administrator to do this or request an edit by using an {{edit protected}} on the template's talk page. If documentation and categories already exist in a section, enclosed within a <noinclude>...</noinclude> container, move them into the documentation subpage (where they should be enclosed in <includeonly>...</includeonly>), as it is best not to have documentation split across two separate pages.

Automatic creation

Use [create] link at the bottom of the empty documentation box to automatically create a preloaded documentation subpage. Insert the documentation after the top line and categories under the appropriate comment line – leaving the comment in place, so that the layout is preserved when the page is edited in future. Related templates, policy page, projects, etc. can be linked to by adding a "See also" section. Save the subpage.

Manual creation

To create the documentation subpage manually, create a subpage with the name Template:X/doc. See the details at {{Documentation subpage}} or start the page by copy-pasting the following standard wikitext:

{{Documentation subpage}}
== Usage ==


<includeonly>{{Sandbox other||
<!-- Categories below this line -->

}}</includeonly>

The top line will display a message explaining the current page and a link to the template page. Save the subpage and follow instructions in § Use Template:Documentation.

With TemplateData

Instead of manually writing a lead graf and a usage table, the {{Format TemplateData}} template can do most of the job. Simply write your TemplateData in the table interface, and then wrap it into a template call like {{Format TemplateData|1=<templatedata>...</templatedata>}} at the top of the page.

Notes

You may wish to redirect the talk page of the /doc subpage to the talk page of the template itself. Then all talk relating to the template and its documentation will end up on the same talkpage. For example, redirect Template talk:X/doc to Template talk:X.

A documentation page can also be redirected to the /doc subpage of another template, if that covers the usage for both templates. In this case, clicking the links to view or edit the documentation will directly open the target of the redirect. If it is necessary to access the redirect itself (e.g. to remove the redirect and create a separate doc page), go to the template URL by clicking in the location bar at the top of your browser, and add /doc at the end.

Blank

To generate a blank template, which may then be copied from the documentation and pasted into another page, use:

{{subst:#tag:pre|{{subst:Parameters|code|base={{subst:BASEPAGENAME}}}}|style=overflow: auto;}}

Examples

To generate an instance of the template, populated with its own property names, use:

{{subst:Parameters|demo|base={{subst:BASEPAGENAME}}|_base=}}
  • To place the template itself into a category, add the [[Category:Category name]] code inside an <includeonly>...</includeonly> section on the doc subpage. See Wikipedia:Categorization § Templates for guidelines.
  • To create an interwiki link for the template itself, go to Wikidata and follow the instructions for adding links to pages.
  • To place the doc subpage into a category, add the [[Category:Category name]] code inside a <noinclude>...</noinclude> section on the doc subpage.
  • To make the template place an article into a category (when the article includes the template), add the [[Category:Category name]] code inside an <includeonly>...</includeonly> section on the template page. Exact placement within the template code may affect how the category code is executed. See Wikipedia:Categorization § Categorization using templates for guidelines.

/sandbox and /testcases

Before doing changes to a template it can be good to first copy the template code to a sandbox and run some testcases, since the template might be visible on thousands or even millions of pages. If you create subpages named exactly "/sandbox" and "/testcases" to a template then the green {{documentation}} box on the template auto-detects this and will show links to those pages in its header. See Wikipedia:Template sandbox and test cases for more information.

Several templates, one documentation page

When several templates work together or are very similar then it is often clearer and easier to maintain one single documentation page that documents them together. The simplest way to do this is to make a full documentation page at one of the templates, and then make "soft redirects" from the other templates. See, for instance: {{wrap}}.

Directly on a template page

When a documentation subpage has not been created, and the {{documentation}} template is being used with a |content= parameter on the actual template page, then to place the template itself into a category, add [[Category:Category name]] inside the documentation template, after the content. For example, for placement on the actual template page:

<!--Last line of your template code--><noinclude>
{{Documentation
 | content =
<!-- template documentation -->

[[Category:Category name]]
[[Category:Category name2]]
}}</noinclude>

When no documentation is needed

When a template as displayed will link to a page that can serve as the documentation, then separate documentation is superfluous and does not need to be created. For instance, a stub template, using the {{asbox}} template as a base, will already display pre-loaded common documentation for all stub templates using that template, and will not need additional documentation.

Tips and tricks

Here are some tips to facilitate writing documentations:

  • Links to templates like {{Japanese year|1800}} can be inserted by writing {{tlp|Japanese year|1800}}. See {{tlp}} for similar templates.
  • HTML tags like <ref group="note">...</ref> can be easily inserted with {{tag}}. This example is written as {{tag|ref|attribs=group="note"}}
  • Equals sign = can be inserted with {{=}}. For example, {{Citation needed|date=2025-08-05}} is made by {{tlp|Citation needed|date{{=}}2025-08-05}}. Avoid the equivalent notation &#61; which is not easy to read for other editors.
  • Don't forget the single <nowiki /> tag:
  • For a link to a category, use {{cat}}. For example, {{cat|Templates with incorrect parameter syntax}} becomes Category:Templates with incorrect parameter syntax.
  • Use utility templates to quickly build-up documentation , e.g. {{Collapsible option}}. See Category:Documentation shared content templates.
  • To suppress categorization of the /sandbox and /testcases pages of the template (if they exist), use this code at the bottom of the documentation subpage:
<includeonly>{{sandbox other||{{testcases other||
<!-- Categories below this line, please; interwikis at Wikidata -->

}}}}</includeonly>
  • When the template is a child infobox, documentation appears broken. Prevent this by adding the <includeonly> tag:
{{Some infobox (child) template
|  child = <includeonly>yes</includeonly>
| label1 = Hello
|  data1 = World
}}<noinclude>{{documentation}}</noinclude>

See also

hrd什么意思 痰多吃什么好化痰 七月十一是什么星座 得莫利是什么意思 尚清是什么意思
骨折吃什么 臭氧是什么 做乳腺彩超挂什么科 什么什么迷人的成语 尿酸高吃什么降的快
和谐的意思是什么 乳果糖是什么 一什么事情 霄是什么意思 乳腺瘤不能吃什么
虚火是什么意思 公安局是干什么的 三月20号是什么星座 dm表示什么单位 大是大非是什么意思
布洛芬什么时候起效hcv8jop0ns6r.cn 高血压适合做什么运动hcv8jop8ns4r.cn 什么水果热量低hcv8jop8ns0r.cn 蒲公英泡水喝有什么效果hcv8jop3ns6r.cn 曱亢有什么症状hcv9jop4ns5r.cn
台风什么时候到福建hcv9jop5ns5r.cn 宫刑是什么意思cj623037.com 油脂旺盛是什么原因hcv8jop4ns3r.cn 右胸上部隐痛什么原因xinmaowt.com 宫颈纳氏囊肿什么意思bjhyzcsm.com
超七水晶是什么qingzhougame.com 褒义是什么意思hcv8jop2ns1r.cn 产后大出血一般发生在什么时候hcv8jop3ns5r.cn 书房字画写什么内容好hcv7jop9ns5r.cn 嗜酸性粒细胞偏低是什么意思hcv7jop9ns3r.cn
猪心炖什么治失眠hcv7jop9ns0r.cn 深闺是什么意思hcv9jop0ns4r.cn 什么是甲减hcv7jop6ns5r.cn 血小板过低有什么危害cj623037.com 儿童枕头用什么枕芯好hcv9jop0ns6r.cn
百度