# How to edit your theme's code in Ghost

Tutorial · Norbert · 28 Nov 2026 · 5 min read

Source: https://brightthemes.com/blog/ghost-theme-code-editor

Change your theme's templates and CSS right in Ghost Admin with Edit code, then keep those changes safe through your next theme update.

Ghost has a code editor built into Ghost Admin. Choose **Edit code** next to a theme and you get its files in your browser: change a template, a stylesheet or a translation, save, and the site uses the new version a moment later. No download, no unzipping, no upload.

It has been part of Ghost since [Ghost 6.39](https://brightthemes.com/ghost/version-history#v6-39), in May 2026, on Ghost(Pro) and on any self-hosted site that's up to date. This tutorial walks through a change from start to finish, and ends with the part that's easy to miss: what happens to your edits when you update the theme.

## What you need

- A login to Ghost Admin as the Owner or an Administrator. The theme settings, where **Edit code** lives, aren't open to other staff roles.
- Ghost 6.39 or later. On a self-hosted site, update Ghost if you don't see **Edit code** in the theme menu.
- A rough idea of the file you want to change. If theme files are new to you, [Ghost theme structure, explained](https://brightthemes.com/blog/ghost-theme-structure) maps them out.

## 1. Download a copy first

The editor has no undo history once you save, so keep the current version of the theme before you change anything.

1. Open **Settings › Site › Theme**.
2. Open the menu (**⋯**) next to your active theme and choose **Download**.

Keep the zip somewhere safe. If a change goes wrong, you can upload it again and be back where you started.

## 2. Open the editor

In the same menu, choose **Edit code**. Ghost loads the theme's files into the editor: the file tree on the left, the open file on the right.

*Ghost Admin: Settings › Site › Theme › ⋯ › Edit code*

To edit a theme that isn't active, choose **Change theme**, find it in the **Installed** list, open its menu and choose **Edit code** there.

## 3. Find the file to change

Most changes happen in a few places:

| You want to change | Look in |
|---|---|
| The layout around every page (the `<head>`, header, footer) | `default.hbs` |
| Posts, pages, the homepage, tag and author pages | `post.hbs`, `page.hbs`, `index.hbs` or `home.hbs`, `tag.hbs`, `author.hbs` |
| A part used in several places (the header, the post card, the footer) | `partials/` |
| Styles | `assets/css/` |
| Text the theme shows (buttons, labels) | `locales/`, one file per language |
| Settings and image sizes | `package.json` |

Themes differ in the details, so open a few files to get your bearings. A theme with a build step, like most of ours, also has its source styles and scripts (for example `assets/src/`) beside the built files it loads (for example `assets/built/`). The site reads the built files, and the editor doesn't run the build. So for styles in such a theme, add CSS with [code injection](https://brightthemes.com/blog/ghost-code-injection) instead, or edit the theme on your computer and build it there.

## 4. Make the change

Say you want a line of your own in the footer. Open `partials/footer.hbs` (the name varies by theme; search the tree for "footer") and add it inside the footer's markup:

```handlebars
<p class="footer-note">Independent since 2019. Questions? Write to us at hello@example.com.</p>
```

A few habits keep changes safe:

- **Change as little as you can,** and leave Ghost's own helpers in place: `{{ghost_head}}` and `{{ghost_foot}}` in `default.hbs`, `{{body_class}}`, `{{content}}`, and the members markup (`data-members-form`, `data-portal`). Remove one and features such as search, sign-ups or the Portal stop working.
- **Copy before you rewrite.** Paste the original lines into a note before changing them.
- **Use the theme's own class names,** so your markup picks up its styles.

The tree's buttons create, rename and delete files and folders, if you need a new partial. The editor works with text files: `.hbs`, `.css`, `.js`, `.json`, `.md`, `.yaml`, `.svg` and similar. Images and fonts show in the tree but can't be edited.

## 5. Save the theme

Choose **Save**. Ghost asks you to confirm (**Update theme**), then shows how many files changed. Choose **Replace theme**.

Saving uploads the whole theme again, as if you had uploaded a zip, so Ghost checks it the same way:

- **If the theme has an error Ghost can't run,** you get **Theme not saved** with the problem, and the live theme stays as it was. Fix the file and save again.
- **If there are only warnings,** the theme saves and Ghost lists them. They're usually about features a later Ghost version will drop.

Ghost's own default themes, such as Source, can't be overwritten. For those, Ghost asks for a name and saves your edits as a new theme, with the original's design settings. Activate the copy to use it.

Closing the editor with unsaved changes asks before it throws them away (**Discard changes?**).

## 6. Check the site

Open your site in a new tab, or a private window if it's cached, and look at the pages your change touches, on a phone too. If something looks wrong, open **Edit code** again and fix it, or upload the zip you downloaded in step 1.

## The result

Your change is live, saved in the theme, and it works the same as a change made on your computer and uploaded as a zip.

## Before your next theme update

This is the part to remember. **A theme update replaces every file of the theme.** When you upload a new version, from us or from any theme author, the changes you made in the editor are gone. Ghost only asks whether to overwrite the theme; it has no record of what you changed.

So keep track of what you change:

1. **Note every edit:** the file, and what you changed. A text file or a note in your password manager is enough.
2. **Before updating,** download the current theme (step 1), so you have your edited files to copy from.
3. **After updating,** open **Edit code** on the new version and make the same changes again. Check each one: the new version may have moved or changed the code around it.

Better still, keep changes out of the theme files where you can. Two places survive every update:

- **The theme's design settings,** in **Settings › Site › Design & branding**: colors, fonts, layouts and what shows where. Try them first.
- **Code injection,** in **Settings › Advanced › Code injection**: your own CSS and scripts for the whole site, or for one post. See [how code injection works in Ghost](https://brightthemes.com/blog/ghost-code-injection).

Use **Edit code** for what neither can do, such as changing a template's markup. Our guide to [updating a Ghost theme](https://brightthemes.com/blog/ghost-theme-update-process) covers the update itself, including how to carry over your changes.

## Limits worth knowing

- **One theme at a time, in your browser.** The editor loads the whole theme into the tab, so the theme has to stay under 1,000 files and 32 MB unpacked. Themes almost always are; a theme with its `node_modules` folder zipped in is not.
- **No build step.** Themes that compile their styles and scripts need the build run on a computer (see step 3).
- **No history.** Once saved, the old version is only in the copy you downloaded.
- **Errors block the save, not the site.** A broken template can still slip through if Ghost can run it. That's why step 6 matters.

For larger changes, or ones you'll want to keep across updates, edit the theme on your computer with a code editor and a [Ghost installed on your computer](https://brightthemes.com/blog/ghost-install), check it with [GScan](https://brightthemes.com/blog/ghost-theme-testing), and keep it in version control. For a quick fix or a small addition, **Edit code** is the fastest way there is.
