Extension:MetaDescriptionTag/zh
发行状态: 稳定版 |
|
|---|---|
| 实现 | 标签 |
| 描述 | Provides a tag for adding a custom <meta> description to the document's <head> |
| 作者 | Dror S., Joshua C. Lerner (original author) |
| 最新版本 | 0.5.0 (2026-04-05) |
| MediaWiki | 1.43+ |
| 数据库更改 | 否 |
<metadesc> |
|
| 许可证 | MIT License |
| 下載 | GitHub:
注意: See below |
The MetaDescriptionTag allows users to add a <meta> description into a page's <head>.
Installation
- Download文件,并将其放置在您
extensions/文件夹中的MetaDescriptionTag目录内。 - 請新增下列代码到您的LocalSettings.php文件的底部:
wfLoadExtension( 'MetaDescriptionTag' );
完成 – 請导航至您的wiki上的Special:Version,以验证此扩展已成功安装。
Usage
Once installed, editors of your wiki can add a <meta> description tag by adding the following to the article text:
<metadesc>PageDescription</metadesc>
Where PageDescription would be replaced by the desired meta description.
For example, the above would become:
<meta name="description" content="PageDescription" />
Usage through a template
Say for example you want use a template to set the meta description to something like:
<metadesc>Extract from the article ARTICLETITLE</metadesc>
Create a template called (for example) "Template:Metadesc". Add the following content:
{{#tag:metadesc | Extract from the article {{{1}}} }}
In the article to which you set the meta description, add:
{{metadesc|{{PAGENAME}} }}
Changelog
- 0.5.0
- Modernize for MediaWiki 1.43+: service injection, namespaced hooks
- 0.4.0
This is re-write to make it compatible with more modern MediaWiki practices and make sure it works nicely with MediaWiki 1.27+:
- Extension Registration (extension.json)
- json i18n files
- An actual README file! :-)
- Switching to semantic versioning.
- 0.3
Fix i18n to work with v1.16+, sanitize output using htmlspecialchars().
- 0.2
Change syntax to <metadesc>some content</metadesc> to support template variable substitution.
- 0.1
Initial release.
