This is a static blog website built by docusaurus and hosted by Cloudflare Pages.
The content below will introduce how we implement this website.
Scaffold a skeleton Docusaurus website
npx create-docusaurus@latest my-website classic --typescript
Then npm will install dependencies automatically.
Use yarn
instead of npm
cd
my-website
Remove
my-website/package-lock.json
Run
yarn
Customize docusaurus.config.js
Remove all about
/docs
and clean all files under/blog
Update all default fields
Add i18n
- Add locale switcher in
navbar
config
{
"type": "localeDropdown",
"position": "right"
}
Use
write-translations
CLI, now we add localezh-Hans
by runningyarn write-translations --locale zh-Hans
Update
json
and.md
generated by step 2
Connect to Cloudflare Pages
Sign in Cloudflare Pages.
Connect to Github account and select target repo.
Here's an example of Build configurations
:
Build command: yarn && yarn build
Build output directory: /build
Root directory: /my-website
Build comments on pull requests: Enabled
Here's an example of environment-variables
:
Variable name | Value |
---|---|
NODE_VERSION | 16.13.1 |
YARN_VERSION | 1.22.17 |
Any new commits pushed to main
branch will trigger build.