GitLab pages¶
There are (at least) two options for hosting your Jupyter Book through GitLab:
Using GitLab CI/CD to deploy to an external server (e.g. TU Virtual Machine), see TUD server
Using GitLab Pages to host the book directly on GitLab
GitLab Pages allows you to host static HTML files online from GitLab repositories using GitLab CI/CD. This page includes the how-to instruction. Note that the GL starter kit includes a CI/CD script.
Instructions[1]¶
To get setup with GitLab Pages, ensure that your repository is hosted in GitLab and you are in the root of the Git repository. Create a file called .gitlab-ci.yml with the following content:
image: ghcr.io/prefix-dev/pixi:latest
stages:
- build
- deploy
variables:
PIXI_CACHE_DIR: "$CI_PROJECT_DIR/.pixi"
HOST: "127.0.0.1"
cache:
paths:
- .pixi
before_script:
- pixi --version
build:
stage: build
script:
# install environment from pixi.toml + pixi.lock
- pixi install --locked
# run jupyter-book via pixi environment
- pixi run jupyter-book build --html
artifacts:
paths:
- _build/html
pages:
stage: deploy
script:
- mkdir public
- cp -r _build/html/* public/
artifacts:
paths:
- public
only:
- mainYou must set the HOST - this is a fix for a known issue.
Note that a pixi.toml and pixi.lock file should be included!
A minimal version is shown below.
[workspace]
authors = [{name = "Me", email = "me@me.com"}]
channels = ["conda-forge"]
name = "jbtest"
platforms = ["win-64", "linux-64"]
version = "0.1.0"
[tasks]
[dependencies]
python = ">=3.14.3,<3.15"
jupyter-book = ">=2.1.2,<3"This text is copied and adapted from the MyST documentation where it has been written by Freek Pols