Index ¦ Archives  ¦ Atom  ¦ RSS

Wikipedia "templates" Part 2

I'll start this adventure off with the basics, what one would expect in a template language for an online encyclopedia. We'll be skipping all the text-formatting and layout markup since they're well-documented and very straight forward. You can find it on the Help:Wiki markup page, I'll be skipping the first two sections Layout and Format. Note that those two sections are half that entire page, despite the page having 11 other sections to cover.

Firstly, most non-text-formatting/layout syntax is essentially a series of tokens surrounded symmetrically by some number of {, [, |, + and - with | or : separating internal tokens when appropriate. Text is anything not between these characters.

Links

The first syntax will be that of links; it's the only one that uses square brackets, [, and it essentially has two forms, single and double bracketed, that are combined with parameters and namespaces to handle dozens of uses. The single bracketed link is simply for external links, and can have a name set or not. The below wikicode renders as Example:

[http://example.com/ Example]

If there was no second word, it would have rendered as http://example.com/.

Internal links

These are delimited by double square brackets and use the | for setting the name; the target can be to a whole slew of things, depending on the namespace used, which precedes a : in the target.

For the most part, these links are to other wikipedia articles, so if they're of the following formats that's what they are:

[[target]]
[[target#section]]
[[target|name]]
[[target#section|name]]

However, the following formats are for links with namespaces, which can be to various other types:

[[namespace:target]]
[[namespace:target|name]]

If the namespace is one of the current 26 Wikipedia namespaces, then these are equivalent to the normal article links, except the article titles include :. This is because, in Wikipedia's database, those articles with a namespace are stored next to articles with their namespace intact. It could also be an 'Interwiki' link which could be one of the Wikimedia projects or one of the many (and constantly growing) other wikis known to Wikipedia.

Category namespaces are a little different; if it's like a namespaced link with the namespace 'Category', then it means the current article is in that category. However, if it looks like the next version, then it's actually a link to that category's page:

[[:Category:category_name]]

Images

These syntactically look just like links, but have a File: namespace. There are many options allowed through the | character, as if they're templates, but images still use the [[]] syntax. All the options are laid out in the picture tutorial on Wikipedia, so I'm not going to go over them here, just that this is the general syntax for an image:

[[File:image_filename.type|parameter1|parameter2|caption]]

However, some templates exist for adding layers around images, but they're normally a ton of boilerplate around an [[File:...]] link.

That's all for this round, I'll be explaining templates/transclusion in the next part. And after that, explaining how it all comes together to give anybody trying to parse it all, a headache.

© Fahrzin Hemmati. Built using Pelican. Theme by Giulio Fidente on github.