Install Local Version Of Ghost For Development
Install local version of ghost for development
The local version has minimal caching and logs to stdout making development easier. It should NOT be subsequently converted to a production install (antipattern).
References
- Supported node versions: https://docs.ghost.org/docs/supported-node-versions
- Installing nvm: https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/
- Installing ghost for local development: https://docs.ghost.org/docs/install-local
- Checking nvm install: https://docs.ghost.org/docs/troubleshooting#section-using-nvm
Install
- Check if you have a compatible version of node
a. If not, install nvm via homebrew
brew install nvm
- following the instructions to create ~/.nvm etc since officially not supported this way b. Restart shell c.nvm ls-remote
to list all available versions d. Choose the latest compatible version and install:nvm install 8.11.3
ORnvm install 8.11
to install the latestest patch of 8.11 - Install ghost with npm:
npm i -g ghost-cli@latest
- Create a directory for ghost (e.g.
~/ghost
,cd
into it andghost install local
- If using nvm, following install, double check these two commands give the same path as per the ghost docs:
a.
which ghost
andnpm root -g
Commands
The following commands are useful for local development:
ghost ls
to list running instancesghost start
to start ghost (required after restarting workstation)ghost stop
to stop ghost (or will stop when shutting down workstation)ghost log
to view the logs
Live reload for theme development
Use live reload during theme development to immediately see changes reflected
- create basic theme stub (as per docs)
index.hbs
- template for a list of posts - minimally requiresand
in it (these directives insert ghost specific javascript at the end of the head and end of the body to spam your blog with ga etc)post.hbs
- template for a post - minimally requiresand
in itpackage.json
- containing valid minimal metadata about your theme- places files in [ghost-install-dir]/content/themes/[your-theme-name]
- switch to your new theme using ghost admin - pages will be blank
ghost stop
npm install -g nodemon@latest
- Start ghost using nodemon:
nodemon current/index.js --watch content/themes/[your-theme-name]
(you need to have already switched to your theme via ghost admin - this just simply watches the files and reloads the site if they change)
Themes
Push theme changes to remote Ghost blog using git push
A git remote can be set up to push local changes straight to a server via ssh.
- Initialize a git repo inside your theme directory
- Add remote to your server using ssh e.g. git remote add deploy ssh://me@100.10.9.8/opt/pod/repos/myapp.git