coding help

Template data describes a template and its parameters. It is stored in JSON format and it can be edited with the template data editor.[1][2]

Template data helps people use templates more easily in the visual editor. When people add a template in the visual editor, a dialog box allows them to enter parameters. When you fill out template data, you create the text and options that you display in that dialog box.

All Fandom wikis let you use template data. However, non-Fandom wikis may or may not have this feature.[1]

What template data looks like

A dialog box letting you fill in values for three parameters: box color, color theme, and image

Filling out template data for {{User kind}}

When you add a template to a page in the visual editor, you use a dialog box. The dialog box lets you fill in any parameters. For example, the user might add text, choose a picture, or choose between color options. (This depends on what parameters the template has.)

Template data makes this process much easier. When you make a template, you can use template data to control what the dialog box says. You can describe parameters, give examples, make drop-down lists, and more.

Template data is a great way for template creators to improve user experience for template users. Good template data makes templates much easier to use.

Adding and editing template data

A template data popup showing a description, suggested formatting, and some template parameters

Editing the template data of the {{User kind}} template

Let's say you're making or editing a template and you want to give it template data. Template data may go on a template's main page or its documentation subpage. (If you're editing an existing template with a documentation subpage, check the subpage first. See if it already has template data.)

Here's how to add or edit template data:

  1. Edit the template's page.
  2. Look near the top left. Under the template's name is a box that says "Edit template data." Click it. A pop-up window appears.
  3. Fill out the template description. This helps people understand what your template does. Try to use only a few words.
  4. Near the bottom, it'll let you add parameters. If you have parameters, add them.
  5. Edit the info for each parameter (if applicable). You can do this by clicking on the name of a parameter, then editing the options it shows you. Hit "Done" when you're happy with the parameter. (More instructions are in the next section.)
  6. When you're done, hit "Apply." Look at the end of your template code. Between the <noinclude> tags will be <templatedata> tags. They hold JSON code based on what you entered.

Here's an example of what template data JSON might look like for {{Main}}:

<templatedata>
{
	"params": {
		"1": {
			"label": "Main article",
			"description": "The exact name of the article you want to link to",
			"example": "Accessibility",
			"suggested": true
		}
	},
	"description": "Link to the main article on a topic"
}
</templatedata>

Data for each parameter

Pop-up showing options for the color parameter

Editing the "color" parameter of the {{User kind}} template

You can fill out specific data for each parameter. This isn't required, and you don't have to fill out every single option. It's okay to leave some fields blank.

Here's what each field does. Items marked with an asterisk (*) are ones you're more likely to use often.

Only fill out the ones you need to use. You can leave everything else blank.

Tips and tricks

The first time you open the "Edit template data" box, it takes a "snapshot" of your current parameters. So if you aren't done messing with parameters in your code yet, you may want to wait until you're further along before hitting the button.

You are allowed to edit template data JSON directly. Sometimes, you may do so and then realize you broke it. Often, that's because you forgot or misplaced a comma. Check your commas. Every list item except the last one needs a comma. (Also check your curly braces.)

Best practices

Make your template data easy to read and understand.

See also

External links

References