Templates Wiki
Register
Advertisement
Note: This page serves as a detailed guide for copying templates, as a continuation of Copying and updating templates section of Help:Templates. See that page for a simple guide.
For the guide specifically for Templates Wiki, see Help:Copying.

Contributors throughout Fandom have made all different kinds of templates. It is often simpler to copy an existing template and modify it for your needs rather than create one from scratch. In most cases, you are free to copy templates from other Fandom wikis. Giving credit to the community from which you copied the template is vital.

This 5 step guide will show you a detailed guide on how to copy a template to your wiki.

Step 1: Finding a template[]

Before you copy the template, you should find one first! If you already have, skip this step. Otherwise, continue reading.

There are many places to find templates. One example is this wiki, the the Dev Wiki, and more. See w:Help:Templates#Where to find more templates for more places to find templates.

Note that while you can copy from Wikipedia and other big wikis (like Minecraft Wiki, Terraria Wiki, and such), you shouldn't really do that unless you have the time to get the HUGE dependency tree of templates. You'll either: copy the whole dependency tree (basically every template) on that wiki, have a broken mess of templates, or spend lots of time redesigning them to work without those dependencies. You'll simply use a lot of effort for doing this. It's better if you just "learn" from that wiki, and make your templates based of the code of it. That said, if you really want to, you can. It's just a big challenge.

Step 2: Analyze the template[]

Important note: Some templates like on Templates Wiki and Fandom Developers Wiki have instructions on how to copy the template. It is highly recommended to follow those instructions, as this guide is for general purposes only. If it has instructions, feel free to leave this guide! You can always come back here if you need help with something.

After you found the template, you should analyze the template and see these:

  • What it does
  • How to use it
  • Its depenencies (subtemplates, Lua, extensions, etc)

It is highly recommended to know how the template works, because it can give you an advantage when something doesn't work and you already copied the template. If the template has a documentation page, you should read it for it is a "pre-written" guide on how the template works. Having documentation can also help other users when they use the template, too. Even with the documentation, it is still better if you look at the template code and see for yourself.

If the template has CSS or JS dependencies, take note of it. They will be copied later, but won't be a priority for now.

You should have a list/notes with something like:

Template to copy: Template:Example
Wiki: https://example.fandom.com

Dependencies:
* Template:Foo
* Template:Bar
* Module:Bar
* (documentation pages)

Once you know more about the template, and made a list like above, you can proceed with copying it.

Step 3: Copying the template (and dependencies)[]

Now that you (hopefully) have found a template, and analyzed it, it's time to copy it! There are 2 methods...

  • Exporting/importing the templates. Recommended way, since it preserves contribution history and is also a quick method.
  • Manually copy/pasting the templates. A bit slower, but it works everywhere.

Here's a comparison table about this:

Exporting/Importing Manually copy/pasting
Copying method Simply export the templates (by pasting a list of them), then import the template. You'll have to manually copy everything, like documentation, sub templates, and similar.
Speed and ease of copying Fast and easy Slow and complicated
Needed permissions Anyone (even logged-out users) can export pages, but only administrators can import them to the wiki. Registered users can copy/paste templates.
Pros
  • Less prone to typos
  • Can export/import multiple templates at a time
  • Only edit permissions required at destination wiki
  • More likely to catch dependencies by looking at code before you copy it
Cons
  • Administrators permissions needed for import step
  • Easier to overlook dependencies
  • More prone to typos or copying partial code
  • Can be more complicated and time-consuming, especially with multiple templates or lots of sub-templates

Once you decided a method, continue with the following:

Method 1: Exporting then importing[]

If you chose this method, it's very simple to do so.

Exporting the template and dependencies[]

  1. First, get the list you made earlier.
  2. Then, go to Special:Export of the source wiki (the original wiki you wanted to copy). For example, if I wanted to copy a template from "example.fandom.com", simply go to https://example.fandom.com/wiki/Special:Export.
  3. Paste the original template AND the dependency list you made (remove the bullets) on the giant textbox. Make sure to leave every setting as default! So, in the example above, the textbox should only have:
Template:Example
Template:Foo
Template:Bar
Module:Bar
Template:Example/doc
Template:Foo/doc
Template:Bar/doc
Module:Bar/doc
  1. Press Export, and a XML file should be saved. Now, proceed to the next step.

Importing the template and dependencies[]

  1. Make sure you have the file you made earlier.
  2. Go to Special:Import on your wiki (the target wiki). For example, if your wiki name is "foobar.fandom.com", simply go to https://foobar.fandom.com/wiki/Special:Import.
  3. In the form, do these:
    1. Filename: Press "Select a file", then choose the XML file
    2. Interwiki prefix: Type w:c:<interwiki code> (the interwiki code is the subdomain); so for "example.fandom.com", it's w:c:example.
    3. Comment: Add a comment, like Copied from [[w:c:<interwiki code>:Template:<template>]], alongside dependencies and documentation. There are more ways to properly credit the wiki, which we will discuss in Step 4: Finishing the template.
    4. Leave everything else as the default.
  4. Click Upload file. Then you're done!

Method 2: Copying then pasting[]

This is a lot more complicated, since you do everything manually. There are a total of X steps:

  1. Creating base pages in the target wiki
  2. Open the pages in the source wiki
  3. Copy the page's contents one-by-one in the source to the respective page in the target
  4. Repeating until all are done.

Creating base pages in the target wiki[]

  1. Create 8 separate tabs, with the URL of your target wiki AND those pages in the end of the URL. So, for Example Wiki, you should create 8 tabs with a link of:
Template:Example
Template:Foo
Template:Bar
Module:Bar
Template:Example/doc
Template:Foo/doc
Template:Bar/doc
Module:Bar/doc
  1. Click the create button on all of those
  2. Continue to the next step

Open the pages in the source wiki[]

  1. Create another 8 separate tabs, with the URL of your source wiki AND those pages in the end of the URL. So, for FooBar Wiki, you should create 8 tabs with a link of:
Template:Example
Template:Foo
Template:Bar
Module:Bar
Template:Example/doc
Template:Foo/doc
Template:Bar/doc
Module:Bar/doc
  1. Edit all of those pages. Don't do anything yet!

Copy the page's contents one-by-one in the source to the respective page in the target[]

  1. In each page in the source wiki, copy the contents to the respective page in the target wiki. So, for our example, you should copy the contents of Template:Example on the Example Wiki to the Template:Example page you made earlier in the FooBar Wiki.
  2. For the edit summary, credit the wiki like Copied from [[w:c:<interwiki code>:Template:<template>]], alongside dependencies and documentation. There are more ways to properly credit the wiki, which we will discuss in Step 4: Finishing the template.
  3. Repeat till you're done!

Step 4: Finishing the template[]

Nice, you copied the template (from either one of the methods)! But, you may find that there may be some redlinks or wanted templates, or the template is unstyled. Well, we should try to fix that!

Remove redlinks and wanted templates[]

You can remove the redlinks in these way:

  • Remove the links alltogether
  • Turn them into interwiki(s)
  • Create the pages (if applicable)

For the wanted templates, on the other hand (which are common on /doc pages)...

  • If the template isn't essential or you think it's not required, you could simply remove it alltogether
  • If you have a replacement template, use it instead! Common ones are replacing {{tl}} or {{tlx}} with {{t}} and {{notice}} or {{msgbox}} with {{MessageBox}}.

Installing extensions[]

If you followed all steps correctly, but found random text like "<dpl>" or "{{#var:}}" or similar in the output, it is very likely that the template requires an extension. In this case, the above template requires DPL and Variables. You'll need to contact staff to enable these extensions, or ask your Wiki Representative if you have one. For more information, see Help:Extensions.

Copying CSS or JS[]

If the template seems "unstyled", or isn't that interactive, you'll need to have CSS/JS installed. We'll cover these in a short manner, the Fandom Developers Wiki has a more detailed guide at the Installation page.

CSS[]

For templates with a link to a .css subpage, import and export that page to your wiki. Add an import to that page (Instuctions available at the page Installation in Dev Wiki), and you're done!

If there isn't, look at the template code and find code similar to class="foobar". After you find that class, look at the wiki's MediaWiki:Common.css. Find foobar in the CSS code, and copy that class. For example:

/* Foobar class */
.foobar {
  display:inline;
  border:2px solid green;
}
/* Mini class */
.foobar .box {
  color:red;
}

/* Infoboxes */
.pi-infobox {
  padding:10px;
...

Copy everything to your wiki's common.css. Make sure you credit the wiki you copied. You can credit them using a similar edit summary to this: Copied CSS code from [[w:c:<interwiki code>:MediaWiki:Common.css]] to properly credit them. There are more ways to credit them, see next section.

JS[]

Note: You will need to enable community JavaScript to have JS in your wiki.

For templates with a link to a .js subpage, import and export that page to your wiki. Add an import to that page (Instructions available at the page Installation in Dev Wiki), and you're done!

If there isn't, look at the template code and find code similar to class="foobar". After you find that class, look at the wiki's MediaWiki:Common.js. Find foobar in the JavaScript code, and copy that code. For example:

/* Foobar code */
function foobarCode() {
  let foobar = document.getElementByClassName("foobar");
  foobar.style.fontSize = "10px";
};

/* Main code */
...

Note: Some JS pages might be complicated. You may ask the source wiki's staff for help in these things.

Copy everything to your wiki's common.js. Make sure you credit the wiki you copied. You can credit then using a similar edit summary to this: Copied JS code from [[w:c:<interwiki code>:MediaWiki:Common.js]] to properly credit them. There are more ways to credit them, see next section.


Crediting the wiki[]

There are many ways to credit the source wiki, but you'll need to have at least 1 way. A small notice, or even the edit summary is often recommended.

If you want to, you can create a banner notice that states the original source of the wiki. Here's a simple example:

Create "Template:From Wiki" with the contents:

<div style="padding:1em; display:flex; align-items: center; background-color: #EEE2; border: 1px solid #5556;">
This template is from [[w:c:{{{1}}}:{{{2|{{FULLPAGENAME}}}}}|{{{3|{{lc: {{{1}}} }} Wiki}}}]] ([{{fullurl:w:c:{{{1}}}:{{urlencode:{{{2|{{FULLPAGENAME}}}}}}}|action=credits}} view authors]).</div><includeonly>[[Category:From {{{3|{{lc: {{{1}}} }} Wiki}}}]]</includeonly><noinclude>
Example usage: {{t|From Wiki|templates|Template:Welcome|Templates Wiki}} -> {{From Wiki|templates|Template:Welcome|Templates Wiki}}
</noinclude>

Use the template like: {{From Wiki|templates|Template:Welcome|Templates Wiki}} which shows:

This template is from Templates Wiki (view authors).

Step 5: Done![]

And that's it for this guide! Hopefully you understand now how to copy templates!

Back to Help:Templates

See also[]

Advertisement