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"
Create a GitHub repository
$ git init$ git remote add origin https://github.com/<your-gh-username>/<repository-name>$ git add .$ git commit -m "Initial commit"$ git branch -M main$ git push -u origin main
Deploy with Cloudflare Pages
To deploy your site to Pages:
- Log in to the and select your account.
- In Account Home, select Workers & Pages > Create application > Pages > Connect to Git.
- 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,