Deploy a Hexo site
In this guide, you will create a new Hexo application and deploy it using Cloudflare Pages. You will use the
hexo CLI to create a new Hexo site.
First, install the Hexo CLI with
yarn by running either of the following commands in your terminal:
$ npm install hexo-cli -g# or$ yarn global add hexo-cli
$ brew install hexo
Before you continue
Creating a new project
With Hexo CLI installed, create a new project by running the
hexo init command in your terminal:
$ hexo init my-hexo-site$ cd my-hexo-site$ npm install
Creating a post
Create a new post to give your Hexo site some initial content. Run the
hexo new command in your terminal to generate a new post:
$ hexo new "hello hexo"
Creating a GitHub repository
$ cd my-hexo-site$ git init$ git remote add origin https://github.com/yourgithubusername/githubrepo$ git branch -M main$ git push -u origin main
Deploying with Cloudflare Pages
Deploy your site to Pages by logging in to the > Account Home > Pages and selecting Create a project. Select the new GitHub repository that you created and, in the Set up builds and deployments section, provide the following information:
After completing configuration, click the Save and Deploy button. You should see Cloudflare Pages installing
hexo and your project dependencies, and building your site, before deploying it.
After deploying your site, you will receive a unique subdomain for your project on
Every time you commit new code to your Hexo site, Cloudflare Pages will automatically rebuild your project and deploy it. You will also get access to on new pull requests, so you can preview how changes look to your site before deploying them to production.
Using a specific Node.js version
Some Hexo themes or plugins have additional requirements for different Node.js versions. To use a specific Node.js version for Hexo:
- Go to your Pages project.
- Go to Settings > Environment variables.
- Set the environment variable
NODE_VERSIONand a value of your required Node.js version (for example,