Moving Hugo from GitHub Pages to Codeberg Pages
Table of Contents
Disable GitHub Pages #
Add deprecation notice #
Commit and push it to your repo
Archive repo #
Create Codeberg repo #
Head over to codeberg.org and create an empty repo called pages
,
you can follow the instructions from https://codeberg.page
main
/master
branch is where you’ll store the generated
website only. No markdown, no hugo files nothing. Only the result of site build.Keep the repository empty for now, we’ll come back to it later.
Move your content #
In your old repo where used to be GitHub Pages set a new git remote
git remote set-url origin https://codeberg.org/<user>/pages.git
# rename main/master branch
git branch -m hugo
# copy compiled website up a dir
cp -vr public ../
# move to your main/master Codeberg branch
git checkout -b main
# bring the compiled website on this branch
cp -vr ../public/** .
# commit and push
git add . ; git commit -m 'initial commit'; git push -u origin main
<user>
with your codeberg username. Just set the Codeberg repo as the
main remote.The public/
dir is where your website is dumped after hugo
build, depending
on your installation some may have it in docs/
dir. Adjust this accordingly.
When you create a new Codeberg repo it defaults to main
branch. The name has
no importance as long as the repo settings point to it then your website will
work perfectly fine.
Automate building your site #
Let’s automate the above steps because repetitive tasks are not worth to be done by humans but rather by 🤖
Request Woodpecker CI access #
Head over to codeberg-ci/request-access and request Woodpecker CI access.
You could also donate to Codeberg to support them paying for the infra.
Configure pipeline #
We basically have to replicate the above steps in your CI
and we do that by creating a file at repository root level .woodpecker.yml
You can check out mine as an example .woodpecker.yml
master
(lines 18,20,26) as the main branch. Adjust this accordingly.
|
|
This pipeline was inspired from codeberg.org/Codeberg-CI/examples.
For the CI runner to have push access to the repo
- create a token in your Codeberg profile settings
- head over to https://ci.codeberg.org/repos and locate your repo
- in repo settings create a Secret
CBTOKEN
and paste the created token (we’re refering to it on line 12 in.woodpecker.yml
)
And that’s all! Congratulations, you’ve successfully migrated from GH Pages to Codeberg Pages.
You can brag on their matrix channel #codeberg.org:matrix.org that you’re all set-up.
Bonus tips #
- Store your assets (ie. pictures, pdfs) with
git-lfs
so that your repo doesn’t become more sluggish. I’ve configured mine for pictures .gitattributes, also you can check the README.md forgit lfs
initial instructions - ignore build directory on your
hugo
branch, for example
hugo
branch will help keeping your commit
history sane and in the event of introducing new content you won’t have to commit
a whole chunk of HTML, CSS and all other unrelated stuff, just your markdown
file containing your blog post.