Hexo has become a little flaky of late, but it’s still my goto software when I need to set up a new blog. It boasts One-Command Deployment, which would be great if I could figure out how to deploy it to anything other than GitHub or Heroku. There may be a way, but I’ve tried nothing and I’m all out of ideas. So instead I’ll deploy with Capistrano, because I want to try it with something other than Rails for a change.
You’re working on Ubuntu with the following installed on a remote machine on which to host a git repository and blog site:
Hit me up in the comments if I’ve missed any basic dependencies. The software immediately pertinent to this post (e.g., Hexo and Capistrano) will be installed as required.
I’m also assuming that you have a remote machine or cloud server on which to host a git repository and Hexo blog site. Your blog will be modified on a local machine and deployed to a production machine with Capistrano. As such, to make things easy, all the software named above needs to be installed locally and remotely.
Detailed instructions are found here, but this is how you do it in a nutshell:
npm should have been installed as part of the
This, of course, is not necessary if you already have a Hexo blog to work with. But if you don’t,
Capistrano talks to your blog’s remote repository when it comes time to deploy. See git remote repository SSH setup for help on how to set this up.
When the blank repository has been initialized on the remote machine, you will need to initialize
git in your local Hexo blog directory (i.e.,
blog/ if you’re following from the previous step). This step is covered in the link provided and repeated here. Assuming you’re in the
If everything is set up correctly, you won’t even need to enter a password to push your first commit.
Write the following to the file:
git, Capistrano needs to be initialized in your project directory:
If successful, you will see something like this:
With regard to the steps previously taken, modify the pre-cooked
config/deploy.rb as appropriate. For example:
config/deploy/production.rb, modify as appropriate once again (out of the box, it should be sufficient to tack this on to the end of the file):
Note: the above assumes that my remote production server has a user named
deploy and that this user can write to the
/home/deploy/my-hexo-blog directory. Ultimately, it is up to you to determine which user deploys and where your blog is located on the file system.
That should do it. If something goes wrong,
will give more details.