This guide covers setting up a Quartz repository on GitLab, configuring GitLab Pages for automatic deployment, and connecting Quartz Syncer.
Create a Quartz Repository
Option 1: Import from GitHub (Recommended)
- Go to GitLab’s New Project page.
- Select Import project > Repository by URL.
- Enter the Quartz repository URL:
https://github.com/jackyzha0/quartz.git - Set your Project name (e.g.,
quartz). - Set Visibility Level to your preference.
- Click Create project.
Option 2: Mirror from GitHub
If you want to keep your GitLab repository in sync with the upstream Quartz repository:
- Create a new project as described above.
- Go to Settings > Repository > Mirroring repositories.
- Add
https://github.com/jackyzha0/quartz.gitas a mirror.
Configure GitLab Pages
Add the CI/CD Configuration
Create a new file .gitlab-ci.yml in the root of your repository with the following content:
stages:
- build
- deploy
image: node:22
cache: # Cache modules in between jobs
key: $CI_COMMIT_REF_SLUG
paths:
- .npm/
build:
stage: build
rules:
- if: '$CI_COMMIT_REF_NAME == "v4"'
before_script:
- hash -r
- npm ci --cache .npm --prefer-offline
script:
- npx quartz build
artifacts:
paths:
- public
tags:
- gitlab-org-docker
pages:
stage: deploy
rules:
- if: '$CI_COMMIT_REF_NAME == "v4"'
script:
- echo "Deploying to GitLab Pages..."
artifacts:
paths:
- publicDefault Branch
This configuration deploys when pushing to the default branch. If your Quartz content is on a different branch (e.g.,
v4), replace$CI_DEFAULT_BRANCHwith your branch name.
Verify GitLab Pages is Enabled
- Go to your repository on GitLab.
- Navigate to Deploy > Pages.
- GitLab Pages should be enabled by default for public projects.
Your site will be deployed to <username>.gitlab.io/<project-name>.
Generate an Access Token
- Go to your GitLab Personal Access Tokens page.
- Click Add new token.
- Enter a Token name (e.g.,
Quartz Syncer). - Set an Expiration date (maximum 1 year).
- Under Select scopes, check write_repository.
- Click Create personal access token.
- Copy the generated token immediately.
Token Expiration
GitLab tokens expire after the specified date. GitLab will email you when your token is about to expire.
Configure Quartz Syncer
- Open Obsidian and go to Settings > Community Plugins > Quartz Syncer.
- In the Git settings tab:
- Remote URL:
https://gitlab.com/<username>/<project>.git - Branch: Your default branch (e.g.,
mainorv4) - Provider: GitLab
- Authentication Type: Username & Token/Password
- Username:
oauth2(when using a Personal Access Token) - Access Token: The token you generated
- Remote URL:
A green checkmark indicates a successful connection.
Username Options
You can use either
oauth2or your GitLab username in the Username field. Usingoauth2is recommended for Personal Access Tokens.
Custom Domain (Optional)
- In your repository, go to Deploy > Pages.
- Click New Domain.
- Enter your domain and click Create New Domain.
- Configure your DNS:
- Apex domain (
example.com): Create anArecord pointing to35.185.44.232 - Subdomain (
docs.example.com): Create aCNAMErecord pointing to<username>.gitlab.io
- Apex domain (
- Optionally enable Force HTTPS after DNS verification.
Self-Managed GitLab
If you’re using a self-managed GitLab instance:
- Replace
gitlab.comwith your GitLab instance URL in the Remote URL. - Generate a token from your instance’s Personal Access Tokens page.
- Ensure GitLab Pages is enabled by your administrator.