Skip to content

Until 28 October: open your store and get 3 months of Pro free.

Create your store →
Docs
All topics

Docs Custom themes

Templates and variables

Every variable a custom theme can use on every page, from your store and menu to products, news, staff and votes, with examples in Twig.

Every template gets the variables below. They are plain values and lists: print one with {{ store.name }}, loop over a list with {% for product in products %}. Asking for a variable that does not exist is an error, so a typo never fails silently. Use {% if product.image %} or ?? for a value that can be empty.

Text is escaped for you. Fields that are HTML, like a news post, are already made safe and print as HTML.

On every page

store

Variable What it is
store.name The name of your store.
store.url The front page of your store.
store.shop_url The start of your shop: /shop with a website, else the front page.
store.checkout_url The checkout.
store.purchases_url Where players find their purchases.
store.logo Your logo, or empty.
store.banner Your banner image, or empty.
store.color Your colour, like #0f7a4a.
store.color_text The text colour that reads on your colour: white or dark.
store.tagline Your welcome line from Branding.
store.server_address The address players join on, like play.blockhaven.net.
store.discord_url Your Discord invite.
store.currency Your currency, like EUR.
store.website Whether your website is on.

page

Variable What it is
page.type Which page this is: home, shop, category, product, news, news_post, staff, vote or page.
page.path The path of the page, like /category/ranks.

theme

The built-in theme your own theme started from, when you started from one.

Variable What it is
theme.base Its key, like realm, or empty for the plain starter theme.
theme.mode light or dark, as you set it for that theme under Theme.
theme.settings Its other settings as you set them, like theme.settings.banner_position for Realm or theme.settings.clouds for Daylight.

menu is the menu of your website: Home, Shop, News, Staff, Vote, your pages and your own links. It is empty when your website is off. categories are your categories, pages your pages.

Variable What it is
item.name The text of a menu item.
item.url Where it goes.
item.current Whether the player is on that page.
item.external Only on your own links, which open in a new tab. Use item.external ?? false.
category.name, category.url, category.current A category in categories, and whether it is open now.
category.icon The menu item of the category, or empty.
page.title, page.url A page in pages.
<nav>
  {% for item in menu %}
    <a href="{{ item.url }}"{% if item.current %} aria-current="page"{% endif %}>{{ item.name }}</a>
  {% endfor %}
</nav>

sale

The sale that runs now, or empty: sale.name, sale.label (like "20% off") and sale.ends_at.

modules

The modules you switched on under Theme, as data, so you show them your own way. Each one is empty when it is off or has nothing to show.

Variable What it is
modules.server.online Whether your server is online.
modules.server.count How many players are online.
modules.server.players The first few of them, each with name and head.
modules.discord.url, modules.discord.name Your Discord.
modules.discord.members, modules.discord.online Its members and how many are online, when Discord answered.
modules.goal.raised, modules.goal.goal, modules.goal.percent The monthly goal.
modules.top_buyer.player, modules.top_buyer.head, modules.top_buyer.amount The top buyer of the month.
modules.recent_payments The latest purchases, each with player, head, amount, paid_at and paid_ago (like "2 hours ago").

A head is the address of the player's head, 8 by 8 pixels: show it with image-rendering: pixelated.

A product

Wherever a page has products, each one has these fields.

Variable What it is
product.id, product.name, product.slug The product.
product.url Its page.
product.description Its description as plain text. Use `product.description
product.image Its image, or empty.
product.icon Its Minecraft item, 32 by 32 pixels, or empty. Show it with image-rendering: pixelated.
product.price The price as text, like €9.99, with the sale already off.
product.price_cents The price in cents. Print it with money().
product.list_price, product.list_price_cents The price before the sale. list_price is empty when there is no sale on this product.
product.sale_label Like "20% off", when a sale lowers this product.
product.sale_name, product.sale_ends_at The name of that sale, and when it ends.
product.sold_out Whether it is sold out.
product.available_from When it goes on sale, if that is still to come.
product.can_buy Whether a player can add it now.
product.duration Like "30 days" for a product that runs out, else empty.
product.player_limit Like "1 per player", else empty.
product.cart What cart_button() puts in the cart. You do not need it yourself.
{% for product in products %}
  <article>
    <a href="{{ product.url }}">{{ product.name }}</a>
    {{ money(product.price_cents) }}
    {% if product.can_buy %}{{ cart_button(product) }}{% endif %}
  </article>
{% endfor %}

Per page

home.twig

Variable What it is
blocks The blocks you picked under Website, in your order: welcome, join, news and products.
welcome.title Your welcome title, or "Welcome to" your name.
welcome.text Your welcome text as HTML, or empty.
welcome.tagline Your welcome line from Branding, for when there is no text.
products The products you put on your home.
news Your three newest posts.

shop.twig and category.twig

Variable What it is
category.name, category.description, category.url The category. Empty in a store without categories.
subcategories Its subcategories, each with name and url.
products Its products.
tagline Your welcome line, on the shop only.
comparison The comparison table of the category, if it has one: rows with a label and values, where row.values[product.id] is yes, no, a value of its own, or empty.
popular The id of the product that sold most in the last thirty days, when your theme highlights it (Tiers).

product.twig

Variable What it is
product The product, with everything above.
product.requires The names of products a player needs first, like VIP before MVP.
product.max How many a player can put in the cart at once.
product.stock How many are left, or empty for no limit.
product.max_per_order The most per order you set, or empty.
product.choices The names of the choices a player makes at the checkout, like a colour.
product.upgrades Ranks this one upgrades from, each with name and price: what an owner of that rank pays.
product.category Its category with name and url, and its parent category when it has one.
category_url Its category, for a link back.
more Up to four other products from the same category.

news.twig and news_post.twig

news.twig gets posts, the newest first. news_post.twig gets post, with post.html, the post itself as HTML.

Variable What it is
post.title, post.slug, post.url The post.
post.label Like Update or Event, or empty.
post.excerpt The first lines as plain text.
post.cover Its image, or your banner.
post.published_at When it went up. Format it with `post.published_at

staff.twig

Variable What it is
groups Your groups with people in them, each with name, color and members.
member.name, member.head A member.
member.online Whether they are on your server now.
apply_url Your link to join the team, or empty.

The colour of a group is the colour of its tag in the game. It may not read well as text on your page, so show it as a square or a line.

vote.twig

Variable What it is
sites Your vote sites, each with id, name and url.
site.url_template The address with {player} where the site wants the player's name.
top The top voters of this month, each with player, head and votes.
reward What a vote gives, from Voting.
month The name of this month, for the top voters.
status_url Answers which sites a player voted on today: status_url ~ '?player=Steve' gives {"voted": [1, 3]} with the ids of the sites.

page.twig

content.title and content.html, the page itself as HTML.

Still stuck? Ask in our Discord or mail us at hello@minecraftstore.io, and a person answers.