Skip to content

Commit ee89f26

Browse files
docs: integrate Pagefind search, Google Analytics, and feedback buttons (#2670)
## Description ### Key Changes - Added Google Analytics tracking ID. - Added on-page feedback buttons for documentation. - Adds estimated reading time for each page. - Implemented Pagefind to replace the existing documentation search. ### Context: Pagefind Search Implementation Unlike our previous in-memory search, Pagefind generates a highly compressed, pre-calculated search index at build time. To support this: - **CI/CD**: All deployment workflows (Cloudflare Pages, GitHub Pages, and PR Previews) have been updated to automatically run ```npx pagefind --site public``` immediately after the Hugo build step. - **Local Development**: hugo server running solely in memory will no longer render search results by default. Developers must generate the physical files and index them locally using ```hugo --environment development && npx pagefind ...``` before running the local server. - **Docs & Config**: `DEVELOPER.md` and `gemini.md` have been updated with the new local testing instructions, and `.hugo/static/pagefind/` has been added to .gitignore to prevent committing local binary indexes. ### Rationale: Why Pagefind? Why add a new build step and shift away from our default search? Ultimately, we are trading a bit of build-time complexity for a leap in user experience. - Search Engine Experience: Instead of basic title matching or keyword filtering, Pagefind provides relevant results, substring matching, and highlights the exact context of the match directly in the search dropdown. - Better Scaling: It only delivers the exact data chunks needed for a specific query, meaning our docs can grow and search will remain fast. - Cleans Up Deployment Branches: Our previous search solution resulted in numerous offline index files across our `versioned-gh-pages` branch, contributing to repository bloat over time. Pagefind consolidates its compressed chunks into a single pagefind/ directory, keeping our deployment branches clean and tidy. ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 7679d0a commit ee89f26

17 files changed

+367
-15
lines changed

.ci/lint-docs-source-page.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ if has_errors:
118118
sys.exit(1)
119119
print("Success: Source pages validated.")
120120
sys.exit(0)
121-
EOF
121+
EOF

.ci/lint-docs-tool-page.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ if has_errors:
132132
sys.exit(1)
133133
else:
134134
print("Success: All Tool pages passed structure validation.")
135-
EOF
135+
EOF

.github/workflows/deploy_dev_docs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ jobs:
6969
HUGO_BASEURL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/dev
7070
HUGO_RELATIVEURLS: false
7171

72+
- name: Build Pagefind Search Index
73+
run: npx pagefind --site public
74+
7275
- name: Create Staging Directory
7376
run: |
7477
mkdir staging

.github/workflows/deploy_previous_version_docs.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ jobs:
7373
HUGO_RELATIVEURLS: false
7474
HUGO_PARAMS_VERSION: ${{ github.event.inputs.version_tag }}
7575

76+
- name: Build Pagefind Index (Archived Version)
77+
run: npx pagefind --site public
78+
working-directory: .hugo
79+
7680
- name: Deploy to gh-pages
7781
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
7882
with:
@@ -95,6 +99,10 @@ jobs:
9599
HUGO_RELATIVEURLS: false
96100
HUGO_PARAMS_VERSION: ${{ github.event.inputs.version_tag }}
97101

102+
- name: Build Pagefind Index (Root)
103+
run: npx pagefind --site public
104+
working-directory: .hugo
105+
98106
- name: Deploy to root
99107
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
100108
with:
@@ -103,4 +111,4 @@ jobs:
103111
publish_branch: versioned-gh-pages
104112
keep_files: true
105113
allow_empty_commit: true
106-
commit_message: "deploy: docs to root for ${{ github.event.inputs.version_tag }}"
114+
commit_message: "deploy: docs to root for ${{ github.event.inputs.version_tag }}"

.github/workflows/deploy_previous_version_docs_to_cf.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ jobs:
7373
HUGO_RELATIVEURLS: false
7474
HUGO_PARAMS_VERSION: ${{ github.event.inputs.version_tag }}
7575

76+
- name: Build Pagefind Index (Root)
77+
run: npx pagefind --site public
78+
working-directory: .hugo
79+
7680
- name: Deploy to cloudflare-pages
7781
uses: peaceiris/actions-gh-pages@v4
7882
with:
@@ -95,6 +99,10 @@ jobs:
9599
HUGO_RELATIVEURLS: false
96100
HUGO_PARAMS_VERSION: ${{ github.event.inputs.version_tag }}
97101

102+
- name: Build Pagefind Index (Root)
103+
run: npx pagefind --site public
104+
working-directory: .hugo
105+
98106
- name: Deploy to root
99107
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
100108
with:

.github/workflows/deploy_versioned_docs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ jobs:
6363
HUGO_RELATIVEURLS: false
6464
HUGO_PARAMS_VERSION: ${{ steps.get_version.outputs.VERSION }}
6565

66+
- name: Build Pagefind Index (Versioned)
67+
run: npx pagefind --site public
68+
working-directory: .hugo
69+
6670
- name: Deploy
6771
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
6872
with:
@@ -84,6 +88,10 @@ jobs:
8488
HUGO_RELATIVEURLS: false
8589
HUGO_PARAMS_VERSION: ${{ steps.get_version.outputs.VERSION }}
8690

91+
- name: Build Pagefind Index (Root)
92+
run: npx pagefind --site public
93+
working-directory: .hugo
94+
8795
- name: Deploy to root
8896
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
8997
with:

.github/workflows/deploy_versioned_docs_to_cf.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ jobs:
6363
HUGO_RELATIVEURLS: false
6464
HUGO_PARAMS_VERSION: ${{ steps.get_version.outputs.VERSION }}
6565

66+
- name: Build Pagefind Index (Root)
67+
run: npx pagefind --site public
68+
working-directory: .hugo
69+
6670
- name: Deploy
6771
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
6872
with:
@@ -84,6 +88,10 @@ jobs:
8488
HUGO_RELATIVEURLS: false
8589
HUGO_PARAMS_VERSION: ${{ steps.get_version.outputs.VERSION }}
8690

91+
- name: Build Pagefind Index (Root)
92+
run: npx pagefind --site public
93+
working-directory: .hugo
94+
8795
- name: Deploy to root
8896
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
8997
with:

.github/workflows/docs_preview_deploy.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ name: "docs"
1717
permissions:
1818
contents: write
1919
pull-requests: write
20-
20+
2121
# This Workflow depends on 'github.event.number',
2222
# not compatible with branch or manual triggers.
2323
on:
@@ -81,6 +81,9 @@ jobs:
8181
HUGO_ENVIRONMENT: preview
8282
HUGO_RELATIVEURLS: false
8383

84+
- name: Build Pagefind Search Index
85+
run: npx pagefind --site public
86+
8487
- name: Deploy
8588
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
8689
with:

.github/workflows/docs_preview_deploy_cf.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ jobs:
7272
HUGO_ENVIRONMENT: preview
7373
HUGO_RELATIVEURLS: false
7474

75+
- name: Build Pagefind Search Index
76+
run: npx pagefind --site public
77+
7578
- name: Deploy to Cloudflare Pages via Wrangler
7679
id: cf_deploy
7780
uses: cloudflare/wrangler-action@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ node_modules
1313
# hugo
1414
.hugo/public/
1515
.hugo/resources/_gen
16+
.hugo/static/pagefind/
1617
.hugo_build.lock
1718

1819
# coverage

0 commit comments

Comments
 (0)