Skip to content

docs: let contributors preview the documentation site locally - #1501

Open
masiarek wants to merge 2 commits into
Equal-Vote:mainfrom
masiarek:docs/local-preview
Open

docs: let contributors preview the documentation site locally#1501
masiarek wants to merge 2 commits into
Equal-Vote:mainfrom
masiarek:docs/local-preview

Conversation

@masiarek

@masiarek masiarek commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Editing through the GitHub web UI stays the right default for most doc changes — a typo, a sentence, a link fix. Nothing here changes that flow, and Adding Documentation still leads with it.

This adds a second option for the larger cases: creating new pages, or moving things around. There, three things aren't visible in the browser:

  • Front matter can't be checked. parent: has to match the parent page's title: character-for-character, emoji included — the guide already warns "Make sure this matches exactly otherwise your file won't be accessbile!" You currently find out by pushing and waiting for Pages.
  • GitHub's Preview tab isn't this site. It renders GitHub-flavored Markdown, not Jekyll + just-the-docs — no theme, no nav placement, no Liquid.
  • Nav ordering is only visible rendered, since it's relative to every sibling page.

So: a one-command local preview, for when you want it.

cd docs
docker run --rm -v "$PWD":/site -w /site -p 4000:4000 ruby:2.7 \
  sh -c "bundle install && bundle exec jekyll serve --host 0.0.0.0 --port 4000"

Then open http://localhost:4000. Edits rebuild automatically.

Worth noting the docs aren't part of docker-compose.yml — that runs the app (backend, database, Keycloak). Pages builds these straight from docs/, so previewing them means running Jekyll separately.

What's here

docs/Gemfile — installs the github-pages gem, the same one Pages runs, so a local build matches production. ffi is pinned < 1.17 because newer versions require Ruby >= 3.0 and won't resolve against the Ruby 2.7 that github-pages' Jekyll 3.9 expects.

docs/_config.yml — adds repository:. jekyll-github-metadata refuses to build without knowing which repo it is, and normally reads that from the origin remote; the command above mounts only docs/, so .git sits outside the container. Setting it in config makes the preview work with no env var. Inert in production — Pages already knows the repo, and site.github isn't referenced anywhere in these templates. (Happy to drop this and document -e PAGES_REPO_NWO=... on the command instead, if you'd rather keep published config untouched.)

docs/.gitignore — keeps _site/, .jekyll-cache/ and Gemfile.lock out of the repo.

4_adding_documentation.md — a "Previewing your changes locally" section, added after the existing guidance rather than replacing it: the command, a named-volume variant that caches gems between runs, and troubleshooting for the three errors you actually hit (the missing repo name, the ffi/Ruby conflict, and the unmaintained jekyll/jekyll images whose expected tags no longer exist).

Second commit: a small bug this turned up

The "Bold" example on Updating Website Text currently renders on the live site as:

voting_end: '**Voting ends on **'

The {{datetime, datetime}} is missing. Jekyll runs Liquid over page source before Markdown, and that happens inside fenced code blocks too — so Liquid parses the {{...}} as an output tag, fails on the comma, and substitutes nothing. Since that page is what teaches contributors how templated text works, the example is worth having survive.

The same page already handles this correctly in its other two examples (lines 31 and 38), which are wrapped in {% raw %} — this applies the same wrapper to the third. Jekyll prints Liquid Warning: Liquid syntax error (line 62): Expected end_of_string but found comma on every build.

Split into its own commit in case you'd prefer it as a separate PR.

Verified

Full site builds and serves at localhost:4000 with the theme, logo, colour scheme, search and nav intact, and every existing page returning 200. Cold start installs the gem set (a few minutes); with the named-volume cache, rebuilds are ~7 seconds.

Editing docs today means pushing and waiting for GitHub Pages to rebuild --
"Adding Documentation" only describes the GitHub web-UI flow. This adds a
one-command local preview so writers can see a page before they open a PR.

The docs aren't part of docker-compose.yml (that runs the app: backend,
database, Keycloak). GitHub Pages builds them straight from docs/, so previewing
means running Jekyll. One `docker run` is enough:

    docker run --rm -v "$PWD":/site -w /site -p 4000:4000 ruby:2.7 \
      sh -c "bundle install && bundle exec jekyll serve --host 0.0.0.0 --port 4000"

Changes:

- docs/Gemfile -- installs the github-pages gem, the same one Pages runs, so a
  local build matches production. ffi is pinned < 1.17 because newer versions
  require Ruby >= 3.0 and won't resolve against the Ruby 2.7 that
  github-pages' Jekyll 3.9 expects.
- docs/_config.yml -- adds `repository:`. jekyll-github-metadata refuses to
  build without knowing which repo it is, and normally reads that from the
  origin remote; the command above mounts only docs/, so .git sits outside the
  container. Setting it in config makes the preview work with no env var.
  Inert in production -- Pages already knows the repo, and site.github isn't
  referenced anywhere in these templates.
- docs/.gitignore -- keeps _site/, .jekyll-cache/ and Gemfile.lock out of the
  repo.
- 4_adding_documentation.md -- a "Previewing your changes locally" section with
  the command, a named-volume variant so gem installs are cached between runs,
  and troubleshooting for the three errors you actually hit (the missing repo
  name, the ffi/Ruby conflict, and the unmaintained jekyll/jekyll images whose
  tags no longer exist).

Verified: full site builds and serves at localhost:4000 with the theme, logo,
colour scheme, search and nav intact, and every existing page returning 200.
The "Bold" example on Updating Website Text renders as

    voting_end: '**Voting ends on **'

on the live site -- the {{datetime, datetime}} is missing. Jekyll runs Liquid
over page source before Markdown, and that happens inside fenced code blocks
too, so Liquid parses the {{...}} as an output tag, fails on the comma, and
substitutes nothing. The page teaching contributors how templated text works is
the one place the example really has to survive.

The same page already handles this correctly in its other two examples (lines 31
and 38), which are wrapped in {% raw %}. This applies the same wrapper to the
third, which was missed.

Surfaced by the local preview added in the previous commit -- Jekyll prints
"Liquid Warning: Liquid syntax error (line 62): Expected end_of_string but found
comma" on every build, which nobody sees when editing through the GitHub web UI.
@netlify

netlify Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploy Preview for bettervoting ready!

Name Link
🔨 Latest commit 2ab0e7f
🔍 Latest deploy log https://app.netlify.com/projects/bettervoting/deploys/6a778bdfd9307e0008399c95
😎 Deploy Preview https://deploy-preview-1501--bettervoting.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 53ae0b3c-e013-4c0d-b01f-cbc8d7ba4665

📥 Commits

Reviewing files that changed from the base of the PR and between 7bc75a8 and 2ab0e7f.

📒 Files selected for processing (5)
  • docs/.gitignore
  • docs/Gemfile
  • docs/_config.yml
  • docs/contributions/writers/2_updating_website_text.md
  • docs/contributions/writers/4_adding_documentation.md

📝 Walkthrough

Summary by CodeRabbit

  • Documentation
    • Added instructions for previewing the documentation site locally using Docker and Jekyll.
    • Included troubleshooting guidance for common local preview issues.
    • Fixed rendering of a datetime template example in bold text.
    • Configured the documentation site repository metadata for local previews.

Walkthrough

The documentation site now includes Bundler and GitHub Pages configuration. Jekyll artifacts and Gemfile.lock are ignored. Repository metadata supports local previews. Writer documentation adds Docker and Jekyll preview commands with troubleshooting steps. The voting_end example uses raw delimiters to preserve its template syntax during rendering.

Poem

I’m a rabbit with docs in my den,
Jekyll builds pages again.
Raw tags keep time just right,
Gems guide the preview light.
Hop, hop—clear text takes flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: enabling contributors to preview the documentation site locally.
Description check ✅ Passed The description clearly explains the changes, usage, troubleshooting, and verification; screenshots are not applicable, but the template headings are not followed exactly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant