Deploying Hexo on Cloudflare Pages

As the title suggests, this is a tutorial on deploying Hexo on Cloudflare Pages.#

1. Configure Hexo#

Configuring Hexo is simple, just follow the official tutorial.

1. Configure Node.js/Git#

sudo apt install git-core
sudo apt install nodejs

2. Install Hexo#

npm install hexo-cli -g
If you encounter an error, execute the following commands:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
npm install -g jshint
After completion, reinstall Hexo.
After the installation is complete, execute:
echo 'PATH="$PATH:./node_modules/.bin"' >> ~/.profile

2. Configure Wrangler (Cloudflare)#

First, make sure you have a Cloudflare account and are logged in.
npm install wrangler --save-dev
wrangler login
Then, the login page will open in your default browser. Simply log in.

3. Write Content#

The use of Hexo will not be explained here, please refer to the official website for more information.

4. Upload#

Open the terminal and navigate to the root directory of Hexo, make sure there is a public folder in the current directory.
Execute wranger pages deploy public
Choose Create a new project and enter the name of your blog in the next step, which will also be the name of this Pages.
You can simply press Enter at the Enter the production branch name step.
After that, when you see Deployment complete!, it means the publication was successful. The link that follows is the preview link for this deployment.

Frequently Asked Questions#

hexo, wrangler command not found#

This is due to the npm environment variable not being properly configured. Simply add npx before the code you are executing.

Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.