Howto

ยท 341 words ยท 2 minute read

How to set up blogging with Hugo on Gitea in Codeberg ๐Ÿ”—

  1. First create a public repository named ‘pages’ in Codeberg
  2. If your username is foo, then you get a page site in Codeberg as foo.codeberg.page
  3. In a folder use git to clone the repository with

git clone https://codeberg.org/foo/pages.git where foo is your username

  1. You will now have a folder named ‘pages’ in the folder

  2. Install Hugo from their website

  3. Follow their instructions on getting started to set up a site, instructions here

hugo new site blogsite

This will create a new folder named ‘blogsite’ and it will contain a file named ‘config.toml’

  1. Use the following settings in the config.toml
baseURL = "https://foo.codeberg.page" (where foo = your username)
... (other values as default)
theme = "mini" // you can set up any theme you like
publishDir = "blog"

  1. Save the file and exit
  2. Create a new blog post with hugo new posts/my-first-post.md where my-first-post.md is the name of your new blog post

In the post, write what you want to write, remember to set your meta-data correctly:

title: "My First Post"
date: 2019-03-26T08:47:11+01:00
draft: false // this part is important, leave it as 'false' otherwise your site will not show!

Write the post in markdown text format

  1. Once you are done, test how the post will look like with hugo server and view it in localhost:1313

  2. If you are happy with the site, then cd into the folder where your blog resides and generate the static site and blog with hugo

  3. The next steps are important:

  • Copy the contents of the blog folder to the pages folder with the following code

cp -R blogsite/blog/ pages

  1. Now upload the pages to your site with git with
cd pages
git add .
git commit -m "added files to the site"
git push -u origin master

If everything goes well, your site will be live after the changes are reflected on your site.

For any future changes, yoou will need to do:

hugo new posts/name-your--post.md
//set the draft to false

Then repeat steps 10-13