# A New Entry Point for the Blog: Cloudflare Pages Main Site and GitHub Pages Mirror

> This article is currently an experimental machine translation and may contain errors. If anything is unclear, please refer to [original Chinese version](<https://blog.wendain.ing/posts/blog-migration-to-cloudflare-pages/>). I am continuously working to improve the translation.

## TL;DR

The blog's official entry point has been changed from `blog.wendaining.top` to `blog.wendain.ing`, and the actual content is now hosted by Cloudflare Pages. At the same time, `wendaining.github.io` is retained, pointing only to GitHub Pages, so it continues to serve as a directly accessible mirror and also fits the original workflow.

The original workflow remains unchanged: articles and other content are still placed in the `Blog-Source` branch. Each time a commit is made to this branch, GitHub Actions and Cloudflare Pages build and publish the same Hexo blog separately.

## Why migrate

The main reason is that I bought a new domain and never used it (this is indeed pretty cool).

Previously, the blog was fully hosted on GitHub Pages, and the domain `blog.wendaining.top` also pointed directly to `wendaining.github.io`. GitHub access is unstable in some network environments.

So this time I did not abandon GitHub Pages; instead, I added Cloudflare Pages as the official site: everyday visits land on Cloudflare by default, while GitHub Pages is kept as a backup mirror.

The [workflow for deploying a Hexo blog based on GitHub Actions](/en/posts/hexo-workflow-based-on-github-actions/) I wrote earlier still continues to work.

## What was done during migration

### Set up Cloudflare Pages

Cloudflare Pages connects directly to the same GitHub repository and watches the `Blog-Source` branch. The build configuration is consistent with GitHub Actions:

- Node.js 22;
- Run `npm ci && npx hexo generate`;
- Publish the `public` directory.

This way, one commit triggers two independent pipelines: GitHub Actions publishes static files to `main`, while Cloudflare Pages builds and publishes to Cloudflare on its own.

### Reorganizing domains

The current domain relationships are as follows:

- `blog.wendain.ing`: official domain, with content provided by Cloudflare Pages;
- `blog.wendaining.top`: permanent redirect to the new domain, with article paths and query parameters preserved;
- `wendaining-blog.pages.dev`: also permanently redirects to the official domain;
- `wendaining.github.io`: retained as a directly accessible GitHub Pages mirror.

## Current architecture

```mermaid
flowchart TD
    A["向 Blog-Source 提交文章或配置"]
    B["GitHub Actions 构建"]
    C["Cloudflare Pages 构建"]
    D["main 分支：生成后的静态文件"]
    E["wendaining.github.io<br/>GitHub Pages 镜像"]
    F["blog.wendain.ing<br/>Cloudflare Pages 正式站"]
    G["blog.wendaining.top"]
    H["wendaining-blog.pages.dev"]

    A --> B
    A --> C
    B --> D
    D --> E
    C --> F
    G -->|301| F
    H -->|301| F
```

## Impact

### Daily access unified on Cloudflare

When entering from the old domain, Cloudflare returns a 301 directly at the edge, and then the browser visits `blog.wendain.ing`. The old domain no longer loads the full blog page, nor does it first detour to GitHub Pages and redirect again.

Search-engine-related site URLs, Open Graph, and RSS/Atom metadata have also been changed to the new domain.

### Publishing process has basically not changed

When writing articles, you still only need to modify `Blog-Source`. The only difference is that previously a commit was built only by GitHub Actions, whereas now Cloudflare Pages also builds at the same time. The two sides are independent pipelines, so updates may differ by a few dozen seconds; as long as both builds succeed, the final content is consistent.

## Final thoughts

This structure is quite comfortable at present: normal access goes through Cloudflare, GitHub Pages no longer carries main-site traffic, but a static blog that can be accessed and rolled back to at any time is still retained.
