Switch Cloudflare to GitHub Pages

I suddenly thought that Github Pages can be accessed directly, so I don’t need Cloudflare anymore. I can use Github Pages directly, which can save Cloudflare usage.

The content that needs to be changed is as follows:

  • Remove Cloudflare’s original DNS resolution
  • Set custom domain name in Github Pages
  • Set Github Pages domain resolution at the domain registrar
  • Add Hexo deploy configuration file, specifying the repository address of Github Pages

There are still some problems with the switch. Observe again.

Update: No problem, there is a delay in configuring the domain name, don’t switch repositories back and forth. The next step is to configure Github Actions for automatic deployment. It is currently deployed manually.

During the process of switching to Github Actions automatic deployment, I encountered various problems:
First, I had to write the workflow script. After changing several versions, the final version is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true # Checkout private submodules(themes or something else).

# Caching dependencies to speed up workflows. (GitHub will remove any cache entries that have not been accessed in over 7 days.)
- name: Cache node modules
uses: actions/cache@v3
id: cache
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 8
run_install: true

- name: Generate Content
run: pnpm run build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

Then I found that my theme was wrong… I used theme-next/hexo-theme-next, which hasn’t been updated for several years. But there is a repository called next-theme/hexo-theme-next
theme-next and next-theme…
Then I changed the theme. I used the submodule method. I had to delete the original theme, and then pay attention to deleting the configuration in .git/config, and then use submodule add to add the new theme.
There is still a small problem in the theme, muse.js cannot be found, so I changed muse in schema to Pisces

Now I changed the repository name to username.github.io. I will try other repository names later and deploy Github Pages.