Page requests now go through the API (routes/pages.js), which fills the built index.html in for that path before the app loads: title, description, preview image, canonical URL, and structured data (Organization, Event, BlogPosting). Shared links preview the page itself. Unlisted records are noindex; missing ones return 404. /sitemap.xml lists every public, listed page. site.json is the one place for the site's name, address, default description and preview image, and each static page's title and intro, which the pages now read too. Indexing is switched on: robots.txt allows all but /admin and /api and names the sitemap. The browser tab title follows the page. nginx setup, with a fallback to the plain page if the API is down, is in docs/seo.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3.4 KiB
Search and link previews
Each page's HTML carries its own title, description, preview image, canonical address and, where it fits, structured data, so a link shared on Facebook, iMessage, Slack, Discord or X shows that page, and search engines see the right title before any JavaScript runs.
The API does this: nginx sends page requests to it, and it fills the
built index.html in for that path (server/src/routes/pages.js, rules
in server/src/pageMeta.js). It also serves /sitemap.xml.
Where the words come from
| What | Where |
|---|---|
| Site name, address, default description | site.json: title, url, description (blank uses the front page's subhead) |
| Default preview image | site.json: openGraph.image, eg. /uploads/<file> from Admin → Tools → Media. Blank means pages without their own image have none. |
| Static pages (Retreats, Community, History…) | site.json: pages. The page's heading and intro read the same entry, so they can't drift. A new static page needs an entry. |
| Records (events, organizations, teams, awards, people, posts) | The database: the record's name, then its tagline or first paragraph; its own image (an event's card background, else its logo; a post's cover; a person's photo; an organization's logo). SVGs aren't used as previews. |
| Whether search may list it | site.json robots.index for the whole site; per record, published and listed is indexed, published but unlisted is noindex, anything else is a 404. /admin is always noindex. |
Structured data: Organization on the home page, Event on event pages, BlogPosting on posts.
robots.txt is written by the build (vite.config.ts): with indexing
on it allows everything but /admin and /api and names the sitemap;
with it off it blocks everything.
Production setup
-
The API needs to find two files. Both default to the repo layout (
site.jsonat the root, the build indist/); set them on thengu-apiunit if the deploy puts them elsewhere:[Service] Environment=SITE_CONFIG=/srv/ngu-api/site.json Environment=SITE_INDEX=/path/to/the/built/site/index.htmlindex.htmlis reread when it changes, so a frontend deploy doesn't need an API restart. -
In the nginx site, serve files that exist, send everything else to the API, and fall back to the plain
index.htmlif the API is down, so the site still loads (with default previews) during a restart:location = /sitemap.xml { proxy_pass http://127.0.0.1:3001; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location / { try_files $uri @page; } location @page { proxy_pass http://127.0.0.1:3001; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_intercept_errors on; error_page 502 503 504 = @static; } location @static { try_files /index.html =404; }Keep the existing
/api/and/uploads/blocks; they're more specific and still win. Use the port the API listens on. -
Check it:
curl -s https://nextgenerationofunity.org/events/<id> | grep og:titleshould show the event's name, and Facebook's Sharing Debugger orhttps://www.opengraph.xyzwill show the preview. -
Tell Google: add the site in Google Search Console and submit
https://nextgenerationofunity.org/sitemap.xml.