banner
小鱼

小鱼's Blog

Elegantly use Cloudflare to host Hugo

Cloudflare Pages' free policy: 500 submissions per month, unlimited sites, requests, and bandwidth. Each project can have up to 10 custom domains, each site can have up to 20,000 files, and the maximum file size is 25 MB. Only one Pages deployment can be done at a time (usually takes about 2-3 minutes).

Hosting Hugo static pages with Cloudflare can be done elegantly by adding .md files under the "content" folder locally, pushing them to the repository, and letting Cloudflare handle the building and deployment. Cloudflare will deploy the pages extracted from the "public" folder.

Enable Cloudflare Pages:

  1. Go to the workers interface and click on "Create".
  2. Click on "Github" and connect.
  3. Associate the project in Github (make sure to push the Hugo site to the Github repository first).
  4. Enter the configuration by selecting the project.
  5. Choose Hugo as the framework and set the "HUGO_VERSION" to a newer version, such as "0.114.1".
  6. Save and deploy.

Once the deployment is complete, the site can be accessed successfully.

References:

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