Create a MyBB theme with MyStudio: step by step

amtekkie · Today

From nothing to your own MyBB 1.8 theme: copy MyStudio Default or start from scratch, override templates, add CSS and JavaScript, add settings and share it as one ZIP. No PHP needed for a basic theme.

The path
  • Pick an approach (a child theme is usually right)
  • Templates are files named like MyBB's; new files need a full sync
  • Export a package to share it

Pick an approach

ApproachBest for
Child themeChanging parts of an existing theme while it keeps getting updates. Usually the right choice.
Copy MyStudio DefaultA complete theme of your own that no longer follows updates.
From scratchFull control: start with a stylesheet and override templates one by one.

Copy MyStudio Default

  1. Copy themes/mystudio-default/ to themes/my-theme/. Lowercase letters, numbers and hyphens: the folder name is the theme's slug.
  2. Open themes/my-theme/theme.json and give it a new name. Names must be unique: MyStudio tells themes apart by name.
  3. For the sidebar, logo, strings and settings form, also copy inc/plugins/mystudio/themes/mystudio-default/ to inc/plugins/mystudio/themes/my-theme/, and give its functions your own prefix.
  4. On MyStudio → Themes, click Sync to Database on your theme, then Set as Default.
  5. Open the forum and press Ctrl+Shift+R.

Start from scratch

MyBB fills in every template you don't provide with its default, so you can start very small:

themes/my-theme/
├── theme.json
└── css/
    └── global.css
{
    "name": "My Theme",
    "version": "1839",
    "stylesheets": [
        { "name": "global.css", "attachedto": "", "order": 1 }
    ]
}
body { background: #0f172a; color: #e2e8f0; font-family: system-ui, sans-serif; }
a { color: #2dd4bf; }

Sync and set it as default. Your forum now uses MyBB's standard templates with your CSS.

Override templates

Create a file named exactly like the MyBB template, for example themes/my-theme/templates/footer/footer.html. Copy the original from Templates & Style → Templates or from MyStudio Default, change it, and run a full sync (new files always need one).

Keep MyBB's own pieces when you override footer: {$task_image} (runs scheduled tasks), {$auto_dst_detection}, <debugstuff>, {$contact_us} and {$showteamlink}. Without them parts of the forum quietly stop working.

Add JavaScript

Put scripts in themes/my-theme/js/ and load them in a template, usually headerinclude:

<script src="{$mybb->asset_url}/themes/my-theme/js/my-theme.js?v={$mybb->ms_asset_v}"></script>

Keep ?v={$mybb->ms_asset_v} on your CSS and JS links: MyStudio fills it with the time of your last change, so browsers fetch new files instead of cached ones.

Add a screenshot

Put a screenshot.jpg (or PNG or WebP) of the forum index at 1280 × 800 in the theme folder. The Themes page shows it on the card and in a lightbox. A child theme without one shows its parent's.

Give it settings and PHP

  • Settings: define them in inc/plugins/mystudio/themes/my-theme/options.php and read them in templates as {$mybb->ms_theme_options['key']}. See the options schema.
  • PHP: add template variables from inc/plugins/mystudio/themes/my-theme/hooks.php with MyBB hooks:
<?php
if (!defined('IN_MYBB')) {
    die('Direct initialization of this file is not allowed.');
}
global $plugins;
$plugins->add_hook('index_start', 'mytheme_index_greeting');

function mytheme_index_greeting()
{
    global $mybb, $mytheme_greeting;
    $name = $mybb->user['uid'] ? htmlspecialchars_uni($mybb->user['username']) : 'guest';
    $mytheme_greeting = "Hello, {$name}!";
}

Then use {$mytheme_greeting} in the index template. Escape anything a user typed with htmlspecialchars_uni().

Support MyStudio's modules and options

  • List the modules your theme supports in theme.json "modules".
  • Declare which layout choices you handle in "supports"; the Admin CP then offers only those.
  • Keep the modules' hook points in your templates: ficons_{$forum['fid']} for Forum Icons, {$post['button_like']} for likes, {$ms_alerts_header} for the alerts bell, {$banner_style} for profile banners and so on.
  • Use the --ms-* CSS variables (--ms-accent, --ms-border, --ms-surface, --ms-muted …) so modules match your colours.

Details in the theme.json reference. The easiest start is a copy of MyStudio Default, which handles all of it.

Share it as a package

MyStudio → Themes → Export Package downloads the theme with its PHP, settings schema and modules as one ZIP. Others import it with a review screen. See import and export.

Troubleshooting

ProblemFix
My change doesn't showSync, then reload with Ctrl+Shift+R.
My new template is ignoredNew files need a full sync; check the file name matches the template name exactly.
A second copy of my theme appearedYou changed name in theme.json: a new name is a new theme.
My CSS file isn't loadingList it under stylesheets in theme.json and sync.
"Failed the MyBB template security check"The template contains syntax that could run PHP, such as {${…}}. Move logic to hooks.php.
A setting shows as {$mybb->ms_theme_options[…]}The key is misspelt, or options.php isn't in inc/plugins/mystudio/themes/{slug}/.