Skip to content

fix(website): improve crawlability and indexing - #467

Merged
macalbert merged 12 commits into
mainfrom
macalbert-fix-seo-indexing
Jul 26, 2026
Merged

fix(website): improve crawlability and indexing#467
macalbert merged 12 commits into
mainfrom
macalbert-fix-seo-indexing

Conversation

@macalbert

@macalbert macalbert commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

Improve Envilder indexability by returning real 404 responses, consolidating trailing-slash URLs, and publishing crawler discovery signals.

Harden CloudFront redirect query serialization and make the shared static 404 response locale-aware without changing its HTTP 404 status.

Changes

  • Infrastructure: return the generated 404 page with HTTP 404, redirect extensionless URLs to their trailing-slash form, redirect legacy sitemap requests, and safely encode CloudFront query-object redirects.
  • Website: add robots.txt, llms.txt, canonical and hreflang links, localized metadata, structured data, registry-driven locale URLs, and a locale-aware static 404 page.
  • Tests: cover redirects, query serialization, typed CloudFront outcomes, and real error responses; update the synthesized stack snapshot.

Testing

  • pnpm test
  • pnpm lint
  • pnpm --filter @envilder/website build

Related

N/A

Summary by CodeRabbit

  • New Features
    • Added a localized, styled 404 page with a home button.
    • Enhanced SEO outputs with improved canonical/alternate links, JSON-LD, and configurable robots/noindex behavior.
  • Bug Fixes
    • Preserved query strings during CloudFront redirects, including legacy sitemap handling.
    • Improved trailing-slash and index routing for non-API directory-style requests.
    • Updated CloudFront error responses so both 403 and 404 serve /404.html with a 404 status.
  • Documentation
    • Added llms.txt and robots.txt (sitemap index reference).
    • Refreshed translated metadata/page copy across supported languages.
  • Tests
    • Expanded coverage for URL rewrite behavior and CloudFront error mapping.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 26, 2026 19:05
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@github-actions github-actions Bot added bug Something isn't working iac Infrastructure as Code (AWS CDK) size/XL Very large change — 400+ lines / 25+ files; should be split labels Jul 26, 2026
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

CloudFront routing now preserves query strings, normalizes extensionless URLs, and serves 404 responses through /404.html. The website adds localized not-found content, expanded SEO metadata, updated translations, and public crawler resources.

Changes

CloudFront routing

Layer / File(s) Summary
Query-preserving URL normalization
src/iac/lib/stacks/cloudfront-url-rewrite.js, tests/iac/lib/stacks/cloudfrontUrlRewrite.test.ts
Redirects serialize query strings, preserve them in 301 locations, normalize extensionless paths with trailing slashes, and cover sitemap and static-file cases.
CloudFront error-page routing
src/iac/lib/stacks/staticWebsiteStack.ts, tests/iac/lib/stacks/staticWebsiteStack.test.ts
403 and 404 responses now serve /404.html and return HTTP 404, with matching distribution assertions.

Website SEO and localization

Layer / File(s) Summary
Translation contracts and page metadata
src/website/src/i18n/*, src/website/src/pages/{changelog,docs}.astro, src/website/src/pages/{ca,es}/*
Translation types and localized strings add descriptions and not-found content; changelog and docs pages pass descriptions to BaseLayout.
Canonical, alternate, and structured metadata
src/website/src/layouts/BaseLayout.astro
The layout adds optional noindex, canonical and hreflang links, locale-aware URLs, robots metadata, and conditional JSON-LD.
Not-found page and crawler resources
src/website/src/pages/404.astro, src/website/public/{llms.txt,robots.txt}
A styled localized 404 template and public crawler-facing text resources are added.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CloudFront
  participant URLRewriteHandler
  participant Viewer
  CloudFront->>URLRewriteHandler: Forward URI and querystring
  URLRewriteHandler->>URLRewriteHandler: Normalize path and serialize querystring
  URLRewriteHandler-->>Viewer: Return 301 Location with normalized URL
Loading

Possibly related PRs

  • macalbert/envilder#133: Introduced the CloudFront URL rewrite and static website CDK infrastructure updated here.

Suggested labels: enhancement, documentation

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: improving website crawlability and indexing.
Description check ✅ Passed The description covers the PR summary, changes, testing, and related context, which is enough despite not following the template exactly.
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
  • Commit unit tests in branch macalbert-fix-seo-indexing

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves Envilder website crawlability and indexing by making CloudFront serve real 404 responses (instead of index fallback), consolidating extensionless URLs to trailing-slash canonical URLs via a CloudFront Function redirect, and adding crawler discovery + SEO metadata (canonical/hreflang, localized descriptions, structured data, and a noindex 404 page) to the Astro site.

Changes:

  • Update CloudFront distribution behavior: map 403/404 to a real /404.html with HTTP 404, and add viewer-request redirects for extensionless paths → trailing slash (plus legacy /sitemap.xml redirect).
  • Add SEO/crawler signals to the website: robots.txt, llms.txt, canonical + hreflang links, localized meta descriptions, and JSON-LD structured data.
  • Extend and adjust IaC tests/snapshots to cover redirects, query preservation, and 404 error responses.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/iac/lib/stacks/staticWebsiteStack.test.ts Adds assertion coverage for CloudFront custom error responses returning real 404s.
tests/iac/lib/stacks/cloudfrontUrlRewrite.test.ts Updates tests for redirect-based trailing-slash canonicalization and query preservation.
tests/iac/lib/stacks/snapshots/staticWebsiteStack.test.ts.snap Updates synthesized stack snapshot for new CloudFront error/Function behavior.
src/iac/lib/stacks/staticWebsiteStack.ts Switches CloudFront custom error responses to return /404.html with HTTP 404.
src/iac/lib/stacks/cloudfront-url-rewrite.js Rewrites URL handling to redirect extensionless paths to trailing slashes and preserves query strings in redirects.
src/website/src/layouts/BaseLayout.astro Adds canonical/hreflang, optional noindex, and JSON-LD structured data.
src/website/src/pages/404.astro Introduces a dedicated 404 page rendered with noindex.
src/website/src/pages/docs.astro Adds localized meta description support via BaseLayout prop.
src/website/src/pages/changelog.astro Adds localized meta description support via BaseLayout prop.
src/website/src/pages/ca/docs.astro Adds localized meta description support (Catalan).
src/website/src/pages/ca/changelog.astro Adds localized meta description support (Catalan).
src/website/src/pages/es/docs.astro Adds localized meta description support (Spanish).
src/website/src/pages/es/changelog.astro Adds localized meta description support (Spanish).
src/website/src/i18n/types.ts Extends translation types for page descriptions and 404 strings.
src/website/src/i18n/en.ts Adds new SEO descriptions + 404 translations (English).
src/website/src/i18n/ca.ts Adds new SEO descriptions + 404 translations (Catalan).
src/website/src/i18n/es.ts Adds new SEO descriptions + 404 translations (Spanish).
src/website/public/robots.txt Publishes robots.txt + sitemap discovery signal.
src/website/public/llms.txt Publishes an LLM-friendly project summary and key links.

Comment thread tests/iac/lib/stacks/cloudfrontUrlRewrite.test.ts Outdated
Comment thread src/website/src/layouts/BaseLayout.astro Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/iac/lib/stacks/cloudfront-url-rewrite.js`:
- Around line 47-78: Update getQueryString to percent-encode each query
parameter key and value with encodeURIComponent before joining them into the
rebuilt query string, while preserving key-only parameters and the existing
string-query handling.

In `@src/website/src/pages/404.astro`:
- Around line 7-8: Update the 404 page’s fixed `lang` selection so localized
missing routes derive their locale from the requested path or routing context,
falling back to English only when no supported locale is present. Use that
locale for `useTranslations` and localize the home link destination accordingly,
preserving the existing 404 layout.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0cb87f12-721a-4686-bc50-14bff42e6b60

📥 Commits

Reviewing files that changed from the base of the PR and between 52d985a and 8d37a4e.

⛔ Files ignored due to path filters (1)
  • tests/iac/lib/stacks/__snapshots__/staticWebsiteStack.test.ts.snap is excluded by !**/*.snap and included by tests/**
📒 Files selected for processing (18)
  • src/iac/lib/stacks/cloudfront-url-rewrite.js
  • src/iac/lib/stacks/staticWebsiteStack.ts
  • src/website/public/llms.txt
  • src/website/public/robots.txt
  • src/website/src/i18n/ca.ts
  • src/website/src/i18n/en.ts
  • src/website/src/i18n/es.ts
  • src/website/src/i18n/types.ts
  • src/website/src/layouts/BaseLayout.astro
  • src/website/src/pages/404.astro
  • src/website/src/pages/ca/changelog.astro
  • src/website/src/pages/ca/docs.astro
  • src/website/src/pages/changelog.astro
  • src/website/src/pages/docs.astro
  • src/website/src/pages/es/changelog.astro
  • src/website/src/pages/es/docs.astro
  • tests/iac/lib/stacks/cloudfrontUrlRewrite.test.ts
  • tests/iac/lib/stacks/staticWebsiteStack.test.ts

Comment thread src/iac/lib/stacks/cloudfront-url-rewrite.js
Comment thread src/website/src/pages/404.astro Outdated
@macalbert macalbert self-assigned this Jul 26, 2026
Marçal Albert Castellví and others added 5 commits July 26, 2026 21:16
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 26, 2026 19:22

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/website/src/pages/404.astro`:
- Around line 7-8: Update the 404 page’s locale resolution around lang,
useTranslations, Navbar, Footer, and BaseLayout so it derives the requested
locale from the URL when visiting localized routes such as /es/404 or /ca/404
instead of always using defaultLang. Ensure the shared chrome and locale links
use that resolved locale while preserving the existing default-language
fallback.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6e81fa5d-77eb-48a1-bc62-e6c1d1d08151

📥 Commits

Reviewing files that changed from the base of the PR and between 8d37a4e and b599513.

⛔ Files ignored due to path filters (1)
  • tests/iac/lib/stacks/__snapshots__/staticWebsiteStack.test.ts.snap is excluded by !**/*.snap and included by tests/**
📒 Files selected for processing (4)
  • src/iac/lib/stacks/cloudfront-url-rewrite.js
  • src/website/src/layouts/BaseLayout.astro
  • src/website/src/pages/404.astro
  • tests/iac/lib/stacks/cloudfrontUrlRewrite.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/website/src/layouts/BaseLayout.astro
  • src/iac/lib/stacks/cloudfront-url-rewrite.js
  • tests/iac/lib/stacks/cloudfrontUrlRewrite.test.ts

Comment thread src/website/src/pages/404.astro

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Comment thread src/website/src/pages/404.astro Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 26, 2026 19:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Comment thread src/website/src/pages/404.astro Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 26, 2026 20:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.

Align the LLM reference with the llms.txt proposal.

Route models to canonical docs, packages, examples, and current product boundaries.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 26, 2026 20:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.

Separate shipped interfaces and include a minimal map-file example.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 26, 2026 21:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Comment thread src/iac/lib/stacks/cloudfront-url-rewrite.js
Comment thread src/website/src/layouts/BaseLayout.astro
Skip invalid query-object entries so redirects remain available.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 26, 2026 21:44
Capture the intentional malformed-query guard in the synthesized Function.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/iac/lib/stacks/cloudfront-url-rewrite.js:53

  • getQueryString will throw a TypeError if req.querystring is null/undefined (because for...in cannot iterate nullish). Since this edge function already treats the querystring as potentially non-standard (string vs object + skipping malformed entries), add a null/type guard so redirects never fail at the edge.
	function getQueryString(querystring) {
		if (typeof querystring === "string") {
			return querystring ? "?" + querystring : "";
		}

		var parts = [];
		for (var key in querystring) {

Comment thread tests/iac/lib/stacks/__snapshots__/staticWebsiteStack.test.ts.snap
Copilot AI review requested due to automatic review settings July 26, 2026 21:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.

@macalbert
macalbert merged commit 6a98a2b into main Jul 26, 2026
24 checks passed
@macalbert
macalbert deleted the macalbert-fix-seo-indexing branch July 26, 2026 21:54
@coderabbitai coderabbitai Bot mentioned this pull request Jul 28, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working iac Infrastructure as Code (AWS CDK) size/XL Very large change — 400+ lines / 25+ files; should be split

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants