Skip to content

Commit 86ca992

Browse files
Fix GitHub Pages custom domain baseUrl
When Pages is configured with a custom domain, the site is served from the domain root; build with baseUrl "/" and url set to the custom domain to avoid broken JS/CSS asset paths. Made-with: Cursor
1 parent 1352543 commit 86ca992

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
timeout-minutes: 15
12+
env:
13+
# Match production when using a GitHub Pages custom domain.
14+
CATALYST_DOCS_CUSTOM_DOMAIN: 'true'
1215
steps:
1316
- name: Checkout
1417
uses: actions/checkout@v4

.github/workflows/pages.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
build:
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 15
21+
env:
22+
# When the repo has a GitHub Pages custom domain configured (e.g. docs.catalystnet.org),
23+
# the site is served from the domain root and must be built with baseUrl "/".
24+
CATALYST_DOCS_CUSTOM_DOMAIN: 'true'
2125
steps:
2226
- name: Checkout
2327
uses: actions/checkout@v4

site/docusaurus.config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import type * as Preset from '@docusaurus/preset-classic';
44

55
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
66

7+
const useCustomDomain = process.env.CATALYST_DOCS_CUSTOM_DOMAIN === 'true';
8+
79
const config: Config = {
810
title: 'Catalyst Docs',
911
tagline: 'Operators, wallets, builders, and protocol/RPC reference.',
@@ -14,9 +16,11 @@ const config: Config = {
1416
v4: true, // Improve compatibility with the upcoming Docusaurus v4
1517
},
1618

17-
// GitHub Pages (project pages) URL + baseUrl.
18-
url: 'https://catalyst-network.github.io',
19-
baseUrl: '/catalyst-docs/',
19+
// Hosting:
20+
// - GitHub Pages project site: https://catalyst-network.github.io/catalyst-docs/ (baseUrl: /catalyst-docs/)
21+
// - Custom domain: https://docs.catalystnet.org/ (baseUrl: /)
22+
url: useCustomDomain ? 'https://docs.catalystnet.org' : 'https://catalyst-network.github.io',
23+
baseUrl: useCustomDomain ? '/' : '/catalyst-docs/',
2024

2125
// GitHub pages deployment config.
2226
organizationName: 'catalyst-network',

0 commit comments

Comments
 (0)