Installing Ghost locally

Learn how to install Ghost locally.

Installing Ghost locally

We recently migrated our site from a Kinsta hosted WordPress site over to Ghost and needed to update the theming a bit.

If it works anything like WordPress, we assume you need to set up a local environment and edit your theme files.


Install the Ghost CLI

First things first, and that is to install the ghost cli using your terminal.

npm install ghost-cli@latest -g

This will allow you to run any commands from your terminal that are part of their cli.

If you need to see what commands are available you can go ahead and run ghost help from your terminal.

❯ ghost help
ghost [command]

Commands:
  ghost backup                 Backup content & files
  ghost buster                 Who ya gonna call? (Runs `yarn cache clean`)
  ghost check-update           Check if an update is available for a Ghost installation
  ghost config [key] [value]   View or edit Ghost configuration
  ghost doctor [categories..]  Check the system for any potential hiccups when
                               installing/updating Ghost
  ghost export file            Export content from a blog
  ghost import [file]          Import a Ghost export
  ghost install [version]      Install a brand new instance of Ghost
  ghost log [name]             View the logs of a Ghost instance
  ghost ls                     View running ghost processes
  ghost migrate                Run system migrations on a Ghost instance
  ghost restart                Restart the Ghost instance
  ghost run                    Run a Ghost instance directly (used by process managers and
                               for debugging)
  ghost setup [stages..]       Setup an installation of Ghost (after it is installed)
  ghost start [name]           Start an instance of Ghost
  ghost stop [name]            Stops an instance of Ghost
  ghost uninstall              Remove a Ghost instance and any related configuration files
  ghost update [version]       Update a Ghost instance
  ghost version                Prints out Ghost-CLI version (and Ghost version if one
                               exists)

Global Options:
      --help         Show help                                                   [boolean]
  -d, --dir          Folder to run command in
  -D, --development  Run in development mode                                     [boolean]
  -V, --verbose      Enable verbose output                                       [boolean]
      --prompt       [--no-prompt] Allow/Disallow UI prompting   [boolean] [default: true]
      --color        [--no-color] Allow/Disallow colorful logging[boolean] [default: true]
      --auto         Automatically run as much as possible      [boolean] [default: false]

For more information, see our docs at https://ghost.org/docs/ghost-cli/

Install Ghost

Go ahead and navigate to an empty directory (i.e. folder) on your computer where you are going to install Ghost locally. For example somewhere like ~/ghost.

Next you can go ahead and run

ghost install local

You should see something along the lines of

Ghost was installed successfully! To complete setup of your publication, visit:

    http://localhost:2369/ghost/

in your terminal.

Go ahead and open that url.

This will take you to an initial installation of Ghost with some default settings like site title and your username and password. Set these to whatever you like for local development.

Install the theme in your local environment

Select a theme

Go to Settings > Design then select a design and install it.

Upload a theme

You can also upload a theme if you already have a zip file for it. If so, go to Settings > Design > Upload theme and upload your theme.

Figure out where the theme folders are located

When you finish your initial setup, you can see some files and folders were set up in the directory where you ran the previous commands.

config.development.json
content/
current/
versions/
...and some other hidden files you don't need to worry about right now

After checking through some of the folders, we find /content/themes/theme-folders-here. This is the default location for theme folders and precisely where we'll want to move our themes to that we plan to customize.

This is where we'll want to edit our theme files.

Start local development on your theme

When you open your directory with your code editor (we use VSCode), you'll see instructions on how to work with the theme in the theme's Readme file.

Ours requires using yarn to install the dependencies (it may take a little time). Wait for the dependencies to install.

After your dependencies are installed, run yarn dev to run it locally (or whatever commands they tell you to run).

When we're done with our edits, it looks like we can use yarn zip to zip up the files and upload it back to our hosted Ghost site.