diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..0bb9ad2 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,60 @@ +name: pages + +# Builds the Eleventy site (with the Pagefind search index) and deploys it to +# GitHub Pages at new.blimacake.com. +# +# One-time setup by the owner before the first successful run (see +# docs/site-deploy.md): make the repo public, set Settings > Pages > Source to +# "GitHub Actions", and point the DNS CNAME for new.blimacake.com at +# jposluns.github.io. Until Pages is enabled, the deploy step will fail; that is +# expected. + +on: + push: + branches: [main] + paths: + - "site/**" + - "recipes/**" + - "eleventy.config.js" + - "package.json" + - "package-lock.json" + - "BlimaCake.epub" + - ".github/workflows/pages.yml" + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + build: + name: Build site + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "22" + cache: "npm" + - run: npm ci + - name: Build site and search index + run: npm run build + - uses: actions/upload-pages-artifact@v3 + with: + path: _site + + deploy: + name: Deploy to Pages + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index f6f20d6..8064115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,13 +13,24 @@ Recipe imports are logged both here (summary) and in ### Added +- **Static site: GitHub Pages deploy workflow and custom domain (ADR 0003, PR 4 of the + site phase).** Added [`.github/workflows/pages.yml`](.github/workflows/pages.yml), + which builds the Eleventy site and Pagefind index and publishes it to GitHub Pages, + and a `CNAME` (`new.blimacake.com`) shipped in the built site. Deploys run on + pushes to `main` that touch the site or recipes, and on manual dispatch. Added + [`docs/site-deploy.md`](docs/site-deploy.md) with the one-time owner setup (make the + repo public, set Pages source to GitHub Actions, DNS `CNAME` for + `new.blimacake.com` pointing at `jposluns.github.io`, custom domain and HTTPS) and + a note on moving the apex domain later. The deploy step needs Pages enabled first; + until then it will fail by design. + - **Static site: SEO and Recipe structured data (ADR 0003, PR 3 of the site phase).** Each recipe page now carries schema.org `Recipe` JSON-LD (name, author, category, ingredients, step-by-step instructions, keywords, yield, and image) so search engines can show rich results. Added canonical, Open Graph, and Twitter-card meta to every page (recipe pages use their own photo and an `article` type; other pages use the biscotti image). Added a generated `sitemap.xml` (507 URLs) and `robots.txt` - pointing at it. All absolute URLs use the `github.blimacake.com` domain. + pointing at it. All absolute URLs use the `new.blimacake.com` domain. - **Static site: full-text search (ADR 0003, PR 2 of the site phase).** Added a `/search/` page powered by [Pagefind](https://pagefind.app/), a static search index @@ -39,7 +50,7 @@ Recipe imports are logged both here (summary) and in warm theme in `site/assets/style.css`, and `_site/` to `.gitignore`. Verified: 487 recipe pages and 16 category pages build, all referenced photos copy (jpg, png, webp, avif, gif), and 0 broken internal links. Search (Pagefind), SEO/JSON-LD, and - the Pages deploy workflow with the `github.blimacake.com` domain follow in later + the Pages deploy workflow with the `new.blimacake.com` domain follow in later PRs. ADR 0003 moved to Accepted with the owner's decisions recorded. - **Automated e-book release workflow diff --git a/docs/adr/0003-static-site-phase.md b/docs/adr/0003-static-site-phase.md index 46bc2a7..f5f2b31 100644 --- a/docs/adr/0003-static-site-phase.md +++ b/docs/adr/0003-static-site-phase.md @@ -119,7 +119,7 @@ decisions below. The proposal is accepted. The open questions are resolved as follows: -1. **Domain.** Start on the subdomain `github.blimacake.com`. Once the WordPress site +1. **Domain.** Start on the subdomain `new.blimacake.com`. Once the WordPress site at blimacake.com retires, the apex domain will be redirected to the archive site. 2. **Search.** Use Pagefind (static, zero-maintenance full-text search). 3. **Theme.** A light custom theme in the spirit of blimacake.com. The landing page diff --git a/docs/site-deploy.md b/docs/site-deploy.md new file mode 100644 index 0000000..f6e80ef --- /dev/null +++ b/docs/site-deploy.md @@ -0,0 +1,52 @@ + +# Deploying the site to GitHub Pages + +The website is built from the Markdown by [`.github/workflows/pages.yml`](../.github/workflows/pages.yml) +and published to GitHub Pages at `new.blimacake.com`. This note lists the one-time +setup the owner does, and how deploys happen after that. + +## One-time setup + +1. **Make the repository public.** GitHub Pages needs a public repository on the free + plan. (Pages on a private repository requires a paid plan.) +2. **Turn on Pages with the Actions source.** In the repository, go to + **Settings > Pages > Build and deployment** and set **Source** to + **GitHub Actions**. Until this is done, the workflow's deploy step will fail; that + is expected. +3. **Point the DNS at GitHub.** At the DNS provider for `blimacake.com`, add one + record for the subdomain: + + | Field | Value | + | --- | --- | + | Type | `CNAME` | + | Host / Name | `new` (this makes `new.blimacake.com`) | + | Value / Target | `jposluns.github.io.` | + | TTL | provider default | + + The target is the GitHub Pages host for this account (`jposluns.github.io`), not the + repository. Some providers want the trailing dot on the target; others add it for + you. +4. **Set the custom domain in GitHub.** In **Settings > Pages > Custom domain**, enter + `new.blimacake.com` and save. The repository already ships a `CNAME` file in the + built site, so this field may already be filled in. Once the DNS has propagated, + tick **Enforce HTTPS** (the certificate can take up to about an hour to issue). + +## How deploys happen after setup + +- **Automatically** on every push to `main` that touches the site or the recipes + (`site/**`, `recipes/**`, the Eleventy config, `package*.json`, or the e-book). +- **Manually** at any time from the **Actions** tab: open the **pages** workflow and + choose **Run workflow**. + +Each run rebuilds the whole site and the Pagefind search index from the current +Markdown, so the published site always matches the archive. + +## Later: moving the apex domain + +When the WordPress site at `blimacake.com` retires and you want the bare +`blimacake.com` (not just the `new.` subdomain) to serve this archive, the apex +needs `A` (and `AAAA`) records pointing at GitHub's Pages addresses rather than a +`CNAME`. GitHub publishes the current Pages IP addresses in its documentation; confirm +them there at the time, since hosting addresses can change, and then set the custom +domain to `blimacake.com`. This is a separate step for later, not part of the initial +`new.blimacake.com` launch. diff --git a/eleventy.config.js b/eleventy.config.js index 0a0e190..171ccab 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -10,6 +10,9 @@ export default function (eleventyConfig) { eleventyConfig.addPassthroughCopy({ "assets/branding": "assets/branding" }); eleventyConfig.addPassthroughCopy({ "BlimaCake.epub": "BlimaCake.epub" }); + // Custom-domain marker for GitHub Pages (site/CNAME -> /CNAME). + eleventyConfig.addPassthroughCopy("site/CNAME"); + // Recipe photos, kept at the same relative path the pages reference. for (const ext of ["jpg", "jpeg", "png", "webp", "avif", "gif"]) { eleventyConfig.addPassthroughCopy(`recipes/**/images/*.${ext}`); diff --git a/site/CNAME b/site/CNAME new file mode 100644 index 0000000..48cfdd1 --- /dev/null +++ b/site/CNAME @@ -0,0 +1 @@ +new.blimacake.com diff --git a/site/_data/site.js b/site/_data/site.js index 395c970..bdacab0 100644 --- a/site/_data/site.js +++ b/site/_data/site.js @@ -4,7 +4,7 @@ export default { description: "A home archive of Blima's recipes: cakes, cookies, breads, mains, and more, kept exactly as she made them.", // Set at deploy time via the custom domain; used for absolute links/SEO later. - url: "https://github.blimacake.com", + url: "https://new.blimacake.com", heroImage: "/assets/branding/biscotti_8074926357_o.jpg", epub: "/BlimaCake.epub", };