# 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 Everything below can also be set in the admin, under **Panel → Site settings** (superadmins only): the site's name, description, preview image, favicon and home-screen icon, each static page's title and intro, and whether search engines may list the site. A setting there wins; a blank one falls back to `site.json`. The indexing switch is per database, so the dev server can be off while production is on, from the same build. | 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/` 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 1. The API needs to find two files. Both default to the repo layout (`site.json` at the root, the build in `dist/`), which isn't how the server is deployed: the deploy copies `server/` into `/srv/ngu-api`, so neither file is next to it. Copy `site.json` there with each deploy (eg. rsync it to `/srv/ngu-api/site.json`) and set both on the `ngu-api` unit: ```ini [Service] Environment=SITE_CONFIG=/srv/ngu-api/site.json Environment=SITE_INDEX=/path/to/the/built/site/index.html ``` `index.html` is reread when it changes, so a frontend deploy doesn't need an API restart. 2. In the nginx site, serve files that exist, send everything else to the API, and fall back to the plain `index.html` if the API is down, so the site still loads (with default previews) during a restart: ```nginx # Shared by every block that sends a page to the API. # (Or repeat these lines in each block, as nginx-dev does.) # proxy_http_version 1.1; # proxy_set_header Host $host; # proxy_set_header X-Real-IP $remote_addr; # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # proxy_set_header X-Forwarded-Proto $scheme; location = /sitemap.xml { proxy_pass http://127.0.0.1:3001; } # The home page needs its own block: try_files would otherwise find # the site's folder and serve index.html without asking the API. location = / { proxy_pass http://127.0.0.1:3001; proxy_intercept_errors on; error_page 500 502 503 504 = @static; } location / { try_files $uri @page; } location @page { proxy_pass http://127.0.0.1:3001; proxy_intercept_errors on; error_page 500 502 503 504 = @static; } location @static { try_files /index.html =404; } # (A block that adds headers of its own, eg. Cache-Control, must # repeat the server-level HSTS line: docs/security-headers.md.) # From the API, so Site settings' indexing switch applies; the # build's own robots.txt if the API is down. location = /robots.txt { proxy_pass http://127.0.0.1:3001; proxy_intercept_errors on; error_page 500 502 503 504 = @file; } location @file { try_files $uri =404; } # Uploads are bigger than the /api/ block's 64k limit allows. location = /api/admin/media { proxy_pass http://127.0.0.1:3001; client_max_body_size 26m; proxy_read_timeout 60s; } ``` Keep the existing `/api/` and `/uploads/` blocks; they're more specific and still win. Use the port the API listens on. A 404 from the API (a record that doesn't exist) goes through as it is; 500 to 504 fall back to the plain page. A dev or test server should also send `X-Robots-Tag: noindex, nofollow` and its own blocking `robots.txt`, since it shares the production build's settings: see `nginx-dev` in the repo root. 3. Check it: `curl -s https://nextgenerationofunity.org/events/ | grep og:title` should show the event's name, and Facebook's Sharing Debugger or `https://www.opengraph.xyz` will show the preview. 4. Tell Google: add the site in Google Search Console and submit `https://nextgenerationofunity.org/sitemap.xml`.