World Anvil has 28 templates, many would argue more than you will ever need, but we are worldbuilders, wanting MORE is in our blood!
So! For those that need to make sure that your templates are EXACTLY the way you want them, you now have the Custom Article Templates, let me give you the gist… here we go!
What are Custom Article Templates
Custom Articles templates will allow you to take one of the current templates and expand it / customize it in order to display the information you want, where you want them to appear.
Once you create a custom template you can assign it to one or more of your worlds. Each of the worlds that you have assigned the template to will now have a button for it that will appear on your “Create” dashboard as well as the Green Hammer button.
There are two “modes” Simple and Advanced.
SIMPLE TEMPLATES
Simple templates allow you to make use of all World Anvil Tags in order to prepopulate your templates with content. People commonly use those to add default headers, image locations, containers, sections, and layout like columns.
Simple templates can have the Vignette, All four sidebar locations, Footer and footer notes content adjusted allowing you for quite some flexibility.
For example, if you want to create a template that will have information about the spaceships of your setting by expanding the normal Vehicle template you can add those headers or even reminders/notes for you.
One more super useful thing about custom article templates is that you can write CSS that will be applied specifically to these templates. To do that all you have to do is write your CSS on the “Styling” tab. A good example of usage of this would be to have a specific background that will be shown only on pages of this page. An even more advanced example would be for you to create a container called for example “Crew Compliment” and then write the CSS for it specifically on this template. This will help you make the files of your world’s CSS smaller and easier to work with.
The Content of the Template (under the structure tab)
[container:crew-compliment]
[h4]Crew Compliment[/h4]
–Officers::ENTER_NUMBER_HERE–
–Enlisted::ENTER_NUMBER_HERE–
[/container]The CSS Code: (under the styling tab)
.user-css .crew-compliment {
padding: 20px;
border: 1px solid black;
background: red;
}.user-css .crew-compliment h4 {
text-decoration:underline;
}
ADVANCED TEMPLATES
Advanced templates are the ultimate tool for creating some highly specialized pages. I won’t lie. To make use of the advanced features you will need some good knowledge of HTML, CSS and Twig BUT it certainly worths it if you want to give your world and pages a truly unique style.
Advanced templates allow you to take the base code of the World Anvil templates and write your own HTML the way you want it and then make use of the TWIG variables which hold the information of your written content. This means that by the time you finish with a template it will possibly look nothing like the original World Anvil template. Once again, you can make use of both the basic template tags AND styling to prepare your templates.
Note: To get started you will need to download and read through the file on the bottom right of the edit screen of your edit template interface
Powered by JSON Data
Finally, advanced templates have another trick up their sleeve. the JSON data array.
If for any reason the variables provided by the parent template you have chosen are not enough or they are not the ones you wanted, you now can input data into your templates in the form of JSON.
For example. IF you are a game developer that has written extensive information about their game’s locations, items or characters and you have the information in JSON or a Spreadsheet that can export JSON you can not copy and paste these structured data in the JSON METADATA field. This information will be accessible by your advanced custom template under the variable (array) usermetadata.
Example case
I have created a game about spaceship combat and I have for each of my spaceships the following array
{
“hitpoints”: 12,
“armor_resistance”: 5,
“shield_points”: 200,
“hull_points”:200
}on the advanced part of my template I can have the following code:
<div>
<label for=”armor”>Hit Points:</label>
<span>{{ usermetadata.hitpoints }}</span>
</div>If input the above JSON array into the JSON METADATA field the usermetadata.hitpoints will in fact print its value (12)
How to get started
In order to create a Custom article template, you need to:
- Open your studio tab and then click on Article Templates
- Fill the name of the Template you’d like to create and choose the PARENT template. This is the template type that your template will be extending/altering
- Simple Template
- Once the template is created add any Tags or text you wish on the STRUCTURE tab of your custom article template
- Optionally, you can open the Styling tab and write any CSS you’d like to be used by the template.
- Save your Template
- At this point, your template is not usable in any world. you will need to attach it to one of your worlds. Use the menu on the right side and click to one or more of your worlds that you’d like that template to be available to.
- Advanced Template
- Follow the instructions above regarding Simple templates
- Download the ZIP file with the scaffolding for each parent template
- Use that code in order to find the name of the variables available to you and as the basis for your own template
Important notes:
- In order to delete a template, you first need to detach it from all the worlds that are attached to.
- When creating an advanced template make sure that you are only using variables available to the parent template OR JSON variables from your metadata.
In conclusion
Custom article templates allow you to create ready-made repeatable templates of your most common work and style it the way you want it with way less hassle.
If you are using the advanced features you can completely redesign the way your pages look using HTML and by taking advantage of the JSON METADATA you can make use of information and data that are not even part of the template, to begin with.
In the future
I would very much like to see the JSON metadata to become an API call to any service that you want which will mean you will be able to request data from outside sources by giving a URL and the required credentials, if any in order to present those data in your templates.
A beautiful example of how Templates work
Our amazing Davina has created already some really amazing templates for her world that you can check out here:
Example Custom Nation / Organization
Useful Links
If you need help, join our discord and talk to us in the #custom-articles-and-statblocks-help channel
Trackbacks/Pingbacks