Is it possible to use Hugo in Codeberg Page repositories?

I look that Codeberg (a german git hosting) has the feature for to publish static web content. But the service seems very simple, I’ve searching on his web and I can’t find personal projects that use Hugo. The majority of webs use vanilla html + css (and some js).

As there are some really beautiful themes of Hugo in many places, I will like to use some of them on Codeberg, but it isn’t like Github or Gitlab so, How to use a Hugo theme with Codeberg Page service?

Hugo generates plain html/css/js so you can host it anywhere.

You will most likely need to run Hugo locally and push the generated content (the content of the “public” folder) to the “pages” repo on Codeberg.

Codeberg Pages
Codeberg allows you to publish static web content (HTML, images, etc) with a human-friendly address ({user-name}.codeberg.page).

Create a repository named 'pages' in your user account or organization.
Create static content, HTML, style, fonts or images. Name the homepage file 'index.html'
Push your content to the main branch of the new repository.
You should now be able to access your content using the domain '{user-name}.codeberg.page'.
See also https://codeberg.page/

See your link Codeberg Pages | Codeberg Documentation

That means the following:

  1. remove an existing public directory in your hugo repo
  2. create a repo pages in your codeberg account
  3. clone the repo pages into public (so that the root content of pages is in the “root” of public, no subfolder-games :wink: )
  4. create a bash script (build.sh for this sample) in your repo root and add the following code (what it does follows):
#!/bin/sh

hugo
cd public
git add -A
git commit -m "site update"
git push origin master

Make it executable and run if you want to upload changes to codeberg.

What it does:

  • build the site
  • add the site to your pages repo
  • push them up

That should put the site online on username.codeberg.page.

You can optimize that regarding some points:

  • remove existing built files in public before publishing hugo again (because if you use pipes then old files will clutter up your repo)
  • add a nicer commit message for the site.

I remember having had a script that creates a github pages branch from a public directory, but I can’t find it. That might be easier than having the pages repo inside of your hugo repo.

Thanks for your help. A simple explanation is:

  • Run hugo locally
  • A push the public folder to pages repository on codeberg.com

And… Do I do the same process every new post that I’ll make?

Yes, with any change.

A post was split to a new topic: Hugo does not create a public directory