Join the Fediverse:Template guide: Difference between revisions

From Join the Fediverse
m (Text replacement - "Infobox App" to "Infobox app")
m (Text replacement - "LangSwiInd" to "Language switch")
Tags: Mobile edit Mobile web edit
Line 65: Line 65:
Many pages display a navbar on the bottom, but not in mobile view. To add this to the page just put {{Ic|<nowiki>{{Navbar}}</nowiki>}} on the bottom of the page. If it's a page about a software project, e.g. Mastodon, then use e.g. {{Ic|<nowiki>{{Navbar/Mastodon}}</nowiki>}} instead.
Many pages display a navbar on the bottom, but not in mobile view. To add this to the page just put {{Ic|<nowiki>{{Navbar}}</nowiki>}} on the bottom of the page. If it's a page about a software project, e.g. Mastodon, then use e.g. {{Ic|<nowiki>{{Navbar/Mastodon}}</nowiki>}} instead.


====LangSwiInd====
====Language switch====


This one is rarely needed for basic editing. It simply puts a slash followed by the language code in the text. So e.g. /en, /de, /ja, /he, ...<br>
This one is rarely needed for basic editing. It simply puts a slash followed by the language code in the text. So e.g. /en, /de, /ja, /he, ...<br>
To use it simply put {{Ic|<nowiki>{{LangSwiInd}}</nowiki>}} in the code.
To use it simply put {{Ic|<nowiki>{{Language switch}}</nowiki>}} in the code.


===Content templates===
===Content templates===
Line 85: Line 85:
Generally these are mostly used for tables that float on the right side of an article and display basic info about the subject of the article.
Generally these are mostly used for tables that float on the right side of an article and display basic info about the subject of the article.


For pages that are being or should be translated: Add {{Ic|<nowiki>{{LangSwiInd}}</nowiki>}} within the template prompt, so e.g. {{Ic|<nowiki>{{Infobox app{{LangSwiInd}}}}</nowiki>}} and don't put the infobox within {{Ic|<nowiki><translate></translate></nowiki>}} tags. This way they will automatically be translated.
For pages that are being or should be translated: Add {{Ic|<nowiki>{{Language switch}}</nowiki>}} within the template prompt, so e.g. {{Ic|<nowiki>{{Infobox app{{Language switch}}}}</nowiki>}} and don't put the infobox within {{Ic|<nowiki><translate></translate></nowiki>}} tags. This way they will automatically be translated.


{|class="wikitable"
{|class="wikitable"

Revision as of 18:26, 14 February 2024

This page is supposed to explain to editors what templates are, how to use them and how to edit them.
Not all templates will be explained here, but you should get a general idea about how they work and then be able to use the others as well. You can find all templates in Category:Templates and sub-categories.

If you have any more questions ask User:Paula and she will answer you and then ideally add the missing information to this guide as well.

What are templates?

Templates are generally just any content that is put into a page in the template namespace (pages that start with Template:) and can be used in any other page by simply writing the page name of the template in double braces.
So e.g. if you have a page called Template:Hello with the content "Hello world!" and you write {{Hello}} in any article then that will be displayed as "Hello world!".
Of course templates are rather used for more complicated things than just a short piece of text. See examples below.

How to use existing templates in an article

Beware: If you use any template make sure it displays correctly after your edit:

  • The template displays at all and not just as "Template:Example" in red text
  • There are no broken links or images in the template
  • There are o missing parameters that display e.g. as {{{parameter}}}
  • The template is in the right position
  • Ideally: There are no redundant line breaks

With the graphical editor

When you use the graphic editor (when you click "edit" and not "edit source") there are two ways to insert a template. You can either just type {{ and a popup will let you choose which template you want to use or you choose "Insert" in the menu above and then "Template".
Anyway you'll then usually get a popup asking you for some parameters. Some of them have to be filled, others are optional. On the left side you'll be able to add more parameters that are available, but might not usually be needed.
This depends on the template having template data defined, which not all have (yet).
There are also very simple templates like {{Mastodon}} which will never get template data, because they don't have parameters and can only generate one result. In this case that is:

Mastodon

With the source editor

If you use the source editor you have to type in the name of the template in the correct capitalization within double braces. So e.g. {{Mastodon}} for the example above.
If the template uses parameters you have to write them in the braces as well like this: {{Template name |parameter 1=example |parameter 2=example 2}}.

Examples

Here's a list of some templates and how to use them.

Basic templates

See Category:Basic templates

We do some things differently in this wiki than elsewhere, because we use the translate extension and not have different wikis in every language (like Wikipedia).
The following two templates make sure that links and categories also work on translated pages.

Internal links

For internal links, instead of e.g. [[Main Page]] to link to the Main Page we use {{Internal link |target=Main Page |link-name=Main Page}}.

Categories

Instead of [[Category:Category name]] to add a category to a page we use {{category |category=Category name}}.

Code

To put some code inside a grey box like example code just write {{Ic|example code}}.

Warning small

To make a ❗️harsh warning❗️ just write {{Warning small|harsh warning}}. In this case harsh warning is a custom text, by default {{Warning small}} just puts out ❗️Warning❗️.

Navbar

Many pages display a navbar on the bottom, but not in mobile view. To add this to the page just put {{Navbar}} on the bottom of the page. If it's a page about a software project, e.g. Mastodon, then use e.g. {{Navbar/Mastodon}} instead.

Language switch

This one is rarely needed for basic editing. It simply puts a slash followed by the language code in the text. So e.g. /en, /de, /ja, /he, ...
To use it simply put {{Language switch}} in the code.

Content templates

See Category:Content templates.
These are templates that are simply used to put something in many articles without having to edit each article every time the content updates.

They are:

Infobox templates

Find all of them in Category:Infobox templates.
Generally these are mostly used for tables that float on the right side of an article and display basic info about the subject of the article.

For pages that are being or should be translated: Add {{Language switch}} within the template prompt, so e.g. {{Infobox app{{Language switch}}}} and don't put the infobox within <translate></translate> tags. This way they will automatically be translated.

Name When to use it How to use it
{{Infobox}} For use in Category:What are Fediverse projects? articles. Put it on top of the article, or if there are already <translate> tags then put it right below <languages/><translate>. Write the first paragraph of the article right below the template - no line breaks.
{{Infobox defunct}} Same, but for Fediverse projects that are no longer maintained. Same.
{{Infobox app}} Use in Category:Apps articles. Same as above: On the very top of the article except articles with translate tags.
{{Infobox app short}} Same, if there are no media files for the app uploaded yet. Same.
{{Infobox book}} Infobox about books by fedizens. Same.
{{Infobox instance}} Use on an instance's own page in the Instance: namespace and on the Instances page. On the instance's page put it on top, on the Instances page put it at the place where the instance you want to add classifies.
{{Infobox instance/grey}} Same, but if the instance doesn't meet the criteria for the Instances page. Same.
{{Infobox platform}} Use on a Fediverse project's advanced page. This template is more complicated, use only if you are an experienced template editor
{{Infobox toot}} Use to display a toot in an article Use on top of the page or section it belongs to.

Table cell templates

Find all of them in Category:Table cell templates.
Here is how they look:

✔️ ✖️
No?
🤖 🆕

These have to be used in tables.
If for some reason you ever wanted to use them standalone you'd have to wrap a basic table around them.
So e.g. for Template:Yes you'd have to use this code:

{|class="wikitable"
|{{Yes}}
|}

Name When to use it How to use it
{{Yes}} To display in a table that something exists. You can use e.g. {{Yes|alternative text}} to display "alternative text" instead of the ✔️.
{{No}} Same, for something that doesn't exist. Same.
{{No?}} Same, for something that probably doesn't exist or if you just want a slightly different background color for some reason. Same.
{{Maybe}} Same, for something that might exist. Same.
{{Bot}} Used e.g. in The climate justice movement in the Fediverse to indicate that an account is a bot Same.
{{New}} Same, to indicate something is new. Has slightly different color than the Yes template. Same.

Project, protocol and app templates

Fin them in Category:Software templates, Category:Protocol templates and Category:App templates.
Like the table cell templates above these are used in tables or have to be wrapped in basic tables otherwise as explained above.
See them in use e.g. in The Fediverse in the Fediverse in the last column.

Some examples are:

  • {{Mastodon}}
  • {{Pleroma}}
  • {{Fediverse}}
  • {{ActivityPub}}
  • {{Tusky}}
  • {{Fedilab}}

and these look like this:

Mastodon Pleroma Fediverse
ActivityPub Tusky Fedilab

Warning templates

Find all of them in Category:Warning templates.
These are used on the top of articles to indicate that the article lacks some quality criteria.
They should only be used by people that are part of Project:Quality control after consulting with the oters.

Portal templates and subtemplates

Find them in Category:Portal templates and Category:Subtemplates.
These are templates used to edit sections of the Main Page or pages in Category:Portals.

License templates

Find them in Category:License templates.
These are just used internally on Media pages. If you upload a file and select a license during upload they will be added automatically so ideally they should not have to ever be added manually, but actually there are lots of uploads without licenses defined, so they should be added afterwards.

Use them like this: {{CC-by-4.0 |author= |source=}}. For author just write the name of the license owner and for source you should enter a link or write "own" to indicate that the license owner is a member of this wiki. So e.g. if you upload a file that you created yourself and want to give it the CC-by-sa-4.0 license you should write: {{CC-by-sa-4.0 |author=Your username |source=own}}.

Member templates

Find them in Category:Member templates.
Use them on your user page to indicate you are part of a project.

Templates for templates

Find them in Category:Templates for templates.
These are templates used to create many other templates. Use if you're an experienced template editor.

What you should consider for translations

This section is a draft or missing!
The section still has to be written or at least a lot more information added.


How to create your own templates

This section is a draft or missing!
The section still has to be written or at least a lot more information added.