---
title: "Code Editor"
description: "Edit your theme's Liquid, JSON, CSS and JavaScript files, restore earlier versions, and create custom page templates you can assign to pages"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.firearmcart.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Code Editor

The code editor lets you change your theme's files directly: its layouts, templates, sections, snippets, blocks and CSS and JavaScript. Use it for changes the [Visual Editor](/themes/visual-editor) can't make, such as a [custom page template](#custom-page-templates).

The code editor is a desktop-only screen.

---

## Opening the Code Editor

1. Go to **Store > My Store**
2. On your current theme, or a theme under **Theme library**, open the **⋮** menu and choose **Edit Code**

Changes to your published theme go live as soon as you save them, and the editor doesn't warn you first. To work safely, choose **Duplicate** from the same menu, edit the copy, preview it, and publish it when it's ready.

---

## Finding Your Way Around

- **Files** are grouped into **Assets**, **Blocks**, **Layouts**, **Sections**, **Snippets** and **Templates**. **Search files...** finds files by name, not by what's in them.
- **Tabs.** Each file you open gets its own tab with its own undo history: use the undo and redo buttons, or Ctrl+Z and Ctrl+Y. A dot marks a tab with unsaved changes, and closing it asks whether to save.
- **Assets** lists CSS and JavaScript files. Add images through the media library in the Visual Editor.
- **Theme settings and translations** aren't files here. Change settings in the Visual Editor.

---

## Saving

Click **Save**, or press Ctrl+S (⌘S on a Mac). Each save is checked first:

| File | Checked for |
|------|-------------|
| Liquid files | Liquid that can't be read |
| JSON templates and JSON assets | Invalid JSON |
| Sections and blocks | A `{% schema %}` that isn't valid JSON |
| CSS and JavaScript | Not checked |

If a check fails, nothing is saved and a **Validation Error** explains what to fix. A save can also succeed with **Saved with warnings**, for example when a template uses a section from a plugin that isn't active.

---

## Version History

Every save keeps the file's previous version. To go back to one:

1. Open the file and click **Version history**
2. Pick a version. The oldest, marked **Baseline**, is the file as it was before your first save.
3. Click **Restore**. The version loads into the editor as unsaved changes.
4. Click **Save** to keep it

Nothing changes until you save, and your current content is kept as a version when you do, so a restore can be undone too. Each file keeps its 20 most recent versions plus the Baseline. Deleting a file deletes its history.

---

## Creating and Deleting Files

1. Click **Add new file** below the file list
2. Choose the **File type**: Layout, Template, Section, Snippet, Block or Asset
3. Enter the **File name** without its extension. Use letters, numbers, hyphens, underscores and periods, such as `page.about-us`.
4. Choose the **Extension**
5. Click **Create**

The new file opens empty. Files can't be renamed, and you can't create folders.

You can delete files you created with **Delete** above the editor, but not the theme's own files: those can be edited, not deleted. Deleting can't be undone.

---

## Custom Page Templates

Every page uses your theme's **page** template unless you give it another one. To give a page its own layout, such as an About page with a team section, create a template whose name starts with `page.` and assign it to the page under **Content > Pages**.

### Creating the Template

1. In the code editor, open **Templates**, click **page** and copy everything in it
2. Click **Add new file**, choose **Template**, enter a name that starts with `page.`, such as `page.about-us`, choose **.json** and click **Create**
3. Paste what you copied into the new file and click **Save**

Name the template after the page's URL handle, `page.about-us` for `/pages/about-us`, so the Visual Editor previews it with that page's content.

For the template to show up as a choice:

- **Its name starts with `page.`** A template named `about-us` never appears.
- **The name has no extension.** Type `page.about-us`, not `page.about-us.json`.
- **It's in your published theme.** Pages can only use templates from the live theme, so if you build the template in a copy, publish the copy first.

Use a JSON template. Your storefront builds pages from sections, and a JSON template is a list of them. In a Liquid template, only `{% section %}` tags are used and any other HTML is ignored. Copying **page** gives you its **main-page** section, which shows the page's title and the content you write under **Content > Pages**.

### Assigning It to a Page

1. Go to **Content > Pages** and open the page, or click **Add page**
2. Under **Page Template**, choose your template. `page.about-us` is listed as **About-us Page**.
3. Click **Update Page**, or **Create Page** for a new page

The **Template** column on the Pages list shows which template each page uses. A draft page shows your theme's 404 page to shoppers; append `?preview=true` to its address to see it yourself.

### Designing It in the Visual Editor

Open the [Visual Editor](/themes/visual-editor) and choose your template from the template selector, where `page.about-us` appears as **Page About Us**. Add and arrange sections, then click **Save**.

Keep the **main-page** section: it shows the page's content, and **Add section** doesn't offer it, so it can only be put back in the code editor. For your own HTML, add a **Custom Liquid** section instead of writing it into the template file.

### If a Page Still Shows the Default Layout

- Its **Page Template** under **Content > Pages** is still **Default Page**
- The template isn't in your published theme, for example after you switched themes
- The template's name doesn't start with `page.`, or ends in `.json`

A page whose template can't be found uses the default **page** template.

---

## Related Documentation

- [Visual Editor](/themes/visual-editor) - Arrange sections and theme settings
- [Theme Sections](/themes/sections) - Section settings and schemas
- [Liquid Variables](/themes/liquid-variables) - Objects available in theme code

Source: https://docs.firearmcart.com/themes/code-editor/index.mdx
