sqzass.git

sqzass

~ A static site generator written in Rust
git clone https://github.com/debuman/sqzass.git

docs/content/deploy/codeberg-pages.md (2079B)

      1 +++
      2 title = "Codeberg Pages"
      3 description = "A pages branch, a .domains file, and Forgejo Actions"
      4 weight = 60
      5 toc = true
      6 +++
      7 
      8 Codeberg serves the `pages` branch of a repository at
      9 `https://<user>.codeberg.page/<repo>/`, or the whole of a repository named
     10 `pages` at `https://<user>.codeberg.page/`.
     11 
     12 ## Building it in CI
     13 
     14 ```yaml
     15 # .forgejo/workflows/deploy.yml
     16 on:
     17   push:
     18     branches: [main]
     19 
     20 jobs:
     21   deploy:
     22     runs-on: docker
     23     container:
     24       image: alpine:latest
     25     steps:
     26       - run: apk add --no-cache git nodejs
     27       - uses: actions/checkout@v4
     28       - run: wget -qO- https://github.com/debuman/sqzass/releases/latest/download/sqzass-x86_64-unknown-linux-musl.tar.gz | tar xz --strip-components=1
     29       - run: ./sqzass build
     30       - name: Publish to the pages branch
     31         run: |
     32           cd public
     33           git init -q && git add -A
     34           git -c user.email=ci -c user.name=ci commit -qm "Deploy"
     35           git push -f "https://$GITHUB_ACTOR:${{ secrets.PAGES_TOKEN }}@codeberg.org/$GITHUB_REPOSITORY.git" HEAD:pages
     36 ```
     37 
     38 `nodejs` is there for the Forgejo Actions runner, not for sqzass.
     39 
     40 ## The subpath, again
     41 
     42 Unless the repository is named `pages`, the site lives under `/<repo>/`:
     43 
     44 ```toml
     45 base_url = "https://myuser.codeberg.page/myrepo"
     46 ```
     47 
     48 The failure mode is the same one GitLab has — a build that succeeds and a site
     49 where every link is one level too high. See
     50 [GitLab Pages](@/deploy/gitlab-ci.md) for the longer explanation.
     51 
     52 ## A custom domain
     53 
     54 Codeberg reads a `.domains` file from the root of the served directory. Put it
     55 in `static/` and it comes through with its name intact, the same way `CNAME`
     56 does for GitHub Pages:
     57 
     58 ```
     59 # static/.domains
     60 example.com
     61 www.example.com
     62 ```
     63 
     64 With a custom domain there is no subpath, so `base_url` becomes the domain.
     65 
     66 > [!NOTE]
     67 > `Path::extension()` returns nothing for a name that is all suffix, which is
     68 > why files like `.domains` and `.nojekyll` need handling that files like
     69 > `main.css` do not. sqzass copies them through; it does not try to fingerprint
     70 > a name that is entirely an extension.