doserver.top/content/blog/2025-01-09-HOWTO-a-simple-blog.md
2025-01-09 14:17:46 +00:00

2.8 KiB

+++ title = "HOW-TO: A super simple blog" +++

Someone recently asked me how they can setup a blog. They are a Linux user, so I am (ab)using that to craft a really simple writing process for blogging. The setup is a little bit technically inclined, but I am hoping this is easy enough to follow

Lets begin...

Tech stack

Codeberg pages for hosting our website

Xlog for generating a pre-styled and fairly simple blog, with a lot of automatic features

Directory structure

File Usage
blog/xlog Generates the blog
blog/build-and-upload.sh Uses xlog and then uploads blog to site
blog/index.md Website Homepage (required!)
blog/a_blog_post.md An example blog file
blog/another_blog_post.md Another example blog file
blog/public/ Generated html; uploaded to Codeberg pages

Setting up

  1. Make a codeberg.org account - choose a username for desired "USERNAME.codeberg.page" website
  2. Make a new repository called pages using the plus button next to your profile picture
  3. Make a folder on your pc for your blog
  4. In that folder... down and extract github.com/emad-elsaid/xlog/releases/latest
    1. Probably want xlog-linux-amd64.tar.gz
    2. You only need the xlog binary from here
  5. Make a file called build-and-upload.sh with the following contents:
    • #!/bin/bash
      
      cd "$(dirname "$0")"
      ./xlog -build public
      
      cd public
      git add .
      git commit -m "Update blog"
      git push -u origin main
      
    • This script turns your blog posts into website code and then uploads it to codeberg
  6. Make build-and-upload.sh executable, normally under rightclick->properties
  7. Getting an access token (so we can upload without signing in)
    1. Go to codeberg.org/user/settings/applications
    2. Type in a name for your token... e.g. "blog upload"
    3. Under "Select permissions", set "repository" to "Read and Write"
    4. Press "Generate Token"
    5. Copy the token
  8. Setup your pages folder...
    1. Right click inside your blog folder and "open in terminal"
    2. Run git init
    3. Run git checkout -b main
    4. Run git remote add origin https://YOUR_TOKEN@codeberg.org/YOUR_USERNAME/pages.git
  9. We are setup!
  10. Bonus: Make an application menu entry for upload with something like PinApp. Set the executable to your build-and-upload.sh file

Writing process

Write markdown files (i.e. in beaver notes) and put them in your blog folder

Then run your build-and-upload.sh script

All your change will be at USERNAME.codeberg.page


Note: Remember to write your homepage file index.md

Conclusion

Happy blogging!!