diff --git a/.github/workflows/build-and-preview-docs.yml b/.github/workflows/build-and-preview-docs.yml
new file mode 100644
index 000000000..5b6e8b82c
--- /dev/null
+++ b/.github/workflows/build-and-preview-docs.yml
@@ -0,0 +1,107 @@
+name: Build and Preview Docs
+
+on:
+ pull_request_target:
+ branches: [master]
+ types: [opened, synchronize, reopened, closed]
+
+permissions:
+ contents: write
+ pull-requests: write
+
+concurrency:
+ group: preview-${{ github.event.pull_request.number || github.run_id }}
+ cancel-in-progress: true
+
+defaults:
+ run:
+ shell: bash
+
+jobs:
+ build-and-deploy-preview:
+ runs-on: ubuntu-24.04
+ env:
+ HUGO_VERSION: 0.157.0
+
+ steps:
+ - name: Checkout PR code
+ if: github.event.action != 'closed'
+ uses: actions/checkout@v6
+ with:
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
+ ref: ${{ github.event.pull_request.head.sha }}
+ persist-credentials: false
+ submodules: recursive
+ fetch-depth: 0
+
+ - name: Checkout for cleanup
+ if: github.event.action == 'closed'
+ uses: actions/checkout@v6
+ with:
+ ref: gh-pages
+ fetch-depth: 0
+
+ - name: Install Hugo CLI
+ if: github.event.action != 'closed'
+ run: |
+ wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
+ && sudo dpkg -i ${{ runner.temp }}/hugo.deb
+
+ - name: Install Dart Sass
+ if: github.event.action != 'closed'
+ run: sudo snap install dart-sass
+
+ - name: Setup Node
+ if: github.event.action != 'closed'
+ uses: actions/setup-node@v4
+ with:
+ node-version: "20"
+
+ - name: Install dependencies
+ if: github.event.action != 'closed'
+ run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
+
+ - name: Build PR preview
+ if: github.event.action != 'closed'
+ env:
+ HUGO_ENVIRONMENT: production
+ HUGO_ENV: production
+ HUGO_PREVIEW: "true"
+ run: |
+ hugo \
+ --gc \
+ --minify \
+ --baseURL "/"
+ cat > public/robots.txt <<'EOF'
+ User-agent: *
+ Disallow: /
+ EOF
+
+ - name: Deploy PR preview
+ if: github.event.action != 'closed'
+ uses: rossjrw/pr-preview-action@v1.6.3
+ with:
+ source-dir: ./public
+ preview-branch: gh-pages
+ umbrella-dir: pr-preview
+ action: auto
+ comment: false
+
+ - name: Comment PR with Preview URL
+ if: github.event.action != 'closed'
+ uses: marocchino/sticky-pull-request-comment@v2
+ with:
+ header: pr-preview
+ message: |
+ 🚀 **Preview deployment for PR #${{ github.event.pull_request.number }}**
+
+ 🌐 **Preview URL**: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/
+
+ _This preview will be updated automatically when you push new commits to this PR._
+ - name: Cleanup PR preview on close
+ if: github.event.action == 'closed'
+ uses: rossjrw/pr-preview-action@v1.6.3
+ with:
+ preview-branch: gh-pages
+ umbrella-dir: pr-preview
+ action: remove
diff --git a/.github/workflows/hugo.yaml b/.github/workflows/hugo.yaml
index 3873fd05c..4a3324b25 100644
--- a/.github/workflows/hugo.yaml
+++ b/.github/workflows/hugo.yaml
@@ -12,15 +12,12 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
-# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
- contents: read
- pages: write
- id-token: write
+ contents: write
concurrency:
- group: "pages-deployment"
- cancel-in-progress: true # Only latest deployment runs
+ group: pages-deployment
+ cancel-in-progress: true
# Default to bash
defaults:
@@ -28,8 +25,7 @@ defaults:
shell: bash
jobs:
- # Build job
- build:
+ deploy:
runs-on: ubuntu-24.04
env:
HUGO_VERSION: 0.157.0
@@ -45,34 +41,27 @@ jobs:
with:
submodules: recursive
fetch-depth: 0
- - name: Setup Pages
- id: pages
- uses: actions/configure-pages@v5
+ - name: Setup Node
+ uses: actions/setup-node@v4
+ with:
+ node-version: "20"
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
env:
- # For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify \
- --baseURL "${{ steps.pages.outputs.base_url }}/"
- - name: Upload artifact
- uses: actions/upload-pages-artifact@v3
- with:
- path: ./public
-
- # Deployment job
- deploy:
- environment:
- name: github-pages
- url: ${{ steps.deployment.outputs.page_url }}
- runs-on: ubuntu-24.04
- needs: build
- steps:
+ --baseURL "/"
+ cp CNAME public/CNAME
+ touch public/.nojekyll
- name: Deploy to GitHub Pages
- id: deployment
- uses: actions/deploy-pages@v4
+ uses: peaceiris/actions-gh-pages@v4
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ publish_dir: ./public
+ publish_branch: gh-pages
+ keep_files: true
diff --git a/hugo.toml b/hugo.toml
index b5866d83a..89750d4a2 100644
--- a/hugo.toml
+++ b/hugo.toml
@@ -1,5 +1,7 @@
baseURL = "https://docs.layer5.io"
title = "Layer5 Documentation"
+relativeURLs = true
+canonifyURLs = false
# Language settings
contentDir = "content/en"
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 488cca3a1..27bb81a2d 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -5,7 +5,9 @@
{{ end -}}
{{ $outputFormat := partial "outputformat.html" . -}}
-{{ if and hugo.IsProduction (ne $outputFormat "print") -}}
+{{ if eq (getenv "HUGO_PREVIEW") "true" -}}
+
+{{ else if and hugo.IsProduction (ne $outputFormat "print") -}}
{{ else -}}
diff --git a/layouts/robots.txt b/layouts/robots.txt
new file mode 100644
index 000000000..68059531b
--- /dev/null
+++ b/layouts/robots.txt
@@ -0,0 +1,3 @@
+User-agent: *
+Allow: /
+Disallow: /pr-preview/
diff --git a/netlify.toml b/netlify.toml
deleted file mode 100644
index 4a098aa41..000000000
--- a/netlify.toml
+++ /dev/null
@@ -1,13 +0,0 @@
-# Hugo build configuration for Netlify
-# (https://gohugo.io/hosting-and-deployment/hosting-on-netlify/#configure-hugo-version-in-netlify)
-
-[build]
-command = "npm run build:preview"
-publish = "public"
-
-[build.environment]
-GO_VERSION = "1.23.8"
-HUGO_VERSION = "0.157.0"
-
-[context.production]
-command = "npm run build:production"