spezifisches

A blog with Eleventy on Codeberg

meta eleventy codeberg

I was looking for a quick way to write down some project notes. This inevitably led me to Static Site Generators and I especially looked at Netlify CMS and Jekyll. But I didn't want to rely on 3rd party services and CDNs to serve some simple pages with occasional images.

In the end I picked a very simple Eleventy configuration based on https://github.com/11ty/eleventy-base-blog which doesn't include any resources from 3rd parties at all.

Codeberg Caveats

Codeberg's Terms of Service are quite restrictive compared to Github or Gitlab in allowing only free software licensed projects and excluding "stale mirrors" and reserving the right to remove inactive repositories. (Completely understandable if you don't have unlimited resources like Microsoft/Github.) But they explicitly allow "really small & personal stuff like your journal, config files, ideas or notes" even for private repositories so I think this site is covered by that policy.

Using the base template the output files are generated in the _site directory:

// These are all optional (defaults are shown):
dir: {
input: ".",
includes: "_includes",
data: "_data",
output: "_site",
},

According to codeberg.pages the files are expected to be either in the root directory of the pages repository or in a pages branch of any other repository.

I didn't like the idea of polluting my source repository with generated data so I came up with this solution using a Git submodule:

rm -rf _site
git submodule add git@codeberg.org:spezifisch/pages.git _site
pnpm build

Now all the generated data is located inside another repository which I can purge as I like if it gets too big.

To use this repository conveniently I added a custom script to my package.json:

  "scripts": {
/* ... */
"publish": "eleventy && git submodule foreach 'git add . && git commit -am deploy && git push origin main'",
},

Using pnpm run publish I can now rebuild my site, commit whatever changed and push it to my pages repository so it is immediately publicly accessible.

Update: The command has since gotten a bit more complicated. It would be nice to have a cleaner solution than this.