Skip to content

Add robots.txt and sitemap.xml - #483

Open
jcollie wants to merge 3 commits into
ghostty-org:mainfrom
jcollie:sitemap-robots
Open

jcollie wants to merge 3 commits into
ghostty-org:mainfrom
jcollie:sitemap-robots

Conversation

@jcollie

@jcollie jcollie commented Sep 22, 2026

Copy link
Copy Markdown
Member

Adds robots.txt and sitemap.xml to help improve site searchability.

AI disclosure: Claude Code was used to prepare this PR but the author has thoroughly reviewed and edited the commit logs and this PR description.

jcollie and others added 2 commits September 22, 2026 14:55
Add both as Next.js metadata routes:

- `sitemap.ts` enumerates the home page, the download page and every
  docs page, reusing the same loaders the docs route uses so that a new
  `.mdx` file is listed automatically with no second list to maintain.

- `robots.ts` allows everything and points at the sitemap in production,
  and disallows everything otherwise, mirroring the `X-Robots-Tag:
  noindex` header already set for non-production builds so that a
  preview deployment cannot compete with ghostty.org for the same
  content.

- `site.ts` holds the canonical origin, which was previously hardcoded twice
  in `layout.tsx`, so that page metadata and the sitemap cannot disagree
  about what the canonical host is.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LvxCwouvubuJLt4KwBzarW
`<lastmod>` lets a crawler tell a page that changed last week from one
that has not moved in a year, and decide what to re-fetch. The sitemap
had none, because the timestamps available at build time are file mtimes
and a fresh CI checkout gives every file the same one.

Read the dates from `git log` instead, taking the commit date of the most
recent commit to touch each page's source. Docs pages are dated from their
MDX file; the home and download pages from the sources listed alongside them.

This requires a full clone of the project so `VERCEL_DEEP_CLONE=true`
will need to be set before it starts working as Vercel only does a
shallow clone by default.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LvxCwouvubuJLt4KwBzarW
@vercel

vercel Bot commented Sep 22, 2026

Copy link
Copy Markdown

@jcollie is attempting to deploy a commit to the Ghostty Team on Vercel.

A member of the Team first needs to authorize it.

`openGraph.url` was hardcoded to `https://ghostty.org` in the root layout and
never overridden, so every page on the site -- all 102 docs pages included --
announced the home page as its Open Graph URL. Every shared link previewed as
the home page, and every consumer reading OG data as a canonical hint was told
that the whole site is one page. There was no `<link rel="canonical">` at all.

Add `canonicalMetadata`, which returns both for a site-relative path, and
spread it into the home page, the download page and the docs route, where the
path comes from the same catch-all segments the route already resolves.

`openGraph` cannot simply be inherited from the layout here, because Next.js
replaces it rather than merging it: a segment that declares `openGraph` to set
its own `url` drops the parent's `type`, `siteName` and `images` with it.
Confirmed by building without the spread, which leaves every docs page with an
`og:url` and no preview image at all. The shared fields are therefore defined
once in `metadata.ts` and spread into both the per-page object and the
layout's fallback.

The layout's fallback names no `url`, so a route that does not call
`canonicalMetadata` emits neither it nor a canonical link. That is the right
failure: a missing canonical URL leaves a crawler to work it out, whereas a
wrong one actively claims the page is a duplicate of somewhere else. The
not-found page is the one route that takes this path, and it is already
`noindex`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LvxCwouvubuJLt4KwBzarW
@Uzaaft

Uzaaft commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@jcollie I'm wondering if this can't be split into two PR's?
robotx.txt + sitemap.xml in one without the git-derived dates and priority rankings.

And then we can build upon that in a follow up for the other git-history + SEO + priority stuff?

@jcollie

jcollie commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

I don't think it makes sense to separate the sitemap generation from the date/priority because the whole point of the sitemap is to expose that information to the search engines.

@Uzaaft

Uzaaft commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

I don't think search engines even respect the priority values these days when they are scraping the pages.

@Uzaaft

Uzaaft commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

At least google doesn't. Any apparently never has, according to the intrawebs.

This branch has not been deployed

No deployments
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.

2 participants