I had already finished the move from Netlify to Cloudflare on my other blog, and since the summer holidays gave me some time, I did the migration on this site too.
It was almost the same work as the migration on the other blog, so I was able to move over fairly easily.
Github
To link it with Cloudflare, set the repository in question to allow the integration.
Also, since this is Hugo, create a Public directory inside the repository
Cloudflare
Workers & Pages → Create → Pages tab
In Connect to Git, link cf-scribble on Github, then Bigin setup
| Project name | scribble |
|---|---|
| deployed URL | scribble-xxx.pages.dev |
| Framework | Hugo |
| Build command | hugo -b $CF_PAGES_URL |
| output directory | public |
Later I changed the build command to hugo —gc —minify -b $CF_PAGES_URL
Environment variables
| HUGO_VERSION | 0.130.0 |
|---|---|
| CF_PAGES_URL | https://scribble-xxx.pages.dev |
Save & Deploy
Once the deploy succeeds, confirm that you can connect to https://scribble-xxx.pages.dev
DNS
This site’s domain was already under Cloudflare’s management, set up with a CNAME pointing at netlify
When you set scribble.washo3.com in Cloudflare’s Custom Domains, it takes care of changing Cloudflare’s DNS settings for you
After this, once the verification finishes, the DNS migration is complete
Change CF_PAGES_URL to https://scribble.washo3.com and rebuild
Fixes coming from Netlify
security headers
Delete the _headers that sat directly under the hugo project and create _headers inside the /static/ folder
https://scribble-xxx.pages.dev/*
X-Robots-Tag: noindex
/pubic/*
X-Frame-Options: DENY
/*
Content-Security-Policy: upgrade-insecure-requests
Expect-CT: max-age=7776000, enforce
Referrer-Policy: strict-origin-when-cross-origin
Strict-Transport-Security: max-age=31536000
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Permissions-Policy: geolocation=(); midi=();notifications=();push=();sync-xhr=();accelerometer=(); gyroscope=(); magnetometer=(); payment=(); camera=(); microphone=();usb=(); xr=();speaker=(self);vibrate=();fullscreen=(self);robots.txt
User-agent: *
Disallow:/admin/
Disallow:/categories/
Disallow:/tags/
Sitemap: https://scribble.washo3.com/sitemap.xmlSummary
Up to now I had run this site with a Gitlab repository linked to Netlify, but I decided to migrate because my chances to use Gitlab or Netlify had dropped to almost nothing, and because Cloudflare is said to be faster for access from within Japan.
As things are now, Github’s codebase and copilot are convenient, so I use Github far more often.
Finally, thank you to Netlify and Gitlab for everything so far.