Presets

Settings

Extend or remove the built-in general and seo globals.

The settings() preset gives every Tenon site two globals, general and seo. The admin lists them on its Settings page.

GlobalFields
generaltitle, tagline, favicon
seotitle and description templates, image, noindex

To extend them, spread what settings() returns.

Example

This example adds a phone number to general and removes seo:

tenon.config.ts
import { defineCms } from "tenoncms";
import { settings } from "tenoncms/presets";

const { general } = settings();

export default defineCms({
  // ...
  settings: {
    general: { ...general, fields: { ...general.fields, phone: { type: "text" } } },
    seo: false,
  },
});

The settings option follows two rules:

  • A key you leave out keeps its default.
  • false removes a global. settings: false removes all of them, also the translations global of a localized site.

Read a settings global like any other global:

const general = await cms.getGlobal("general");
general.phone;

Render it

---
const general = await Astro.locals.tenon.getGlobal("general");
---

<footer>
  <strong>{general.title}</strong>
  {general.phone && <a href={`tel:${general.phone}`}>{general.phone}</a>}
</footer>

The head tags of your site read both globals. To learn how, see Site settings in Pages and SEO.

The Settings page

The Settings page lists every global or admin page whose nav has display: "settings". The settings() globals use it, and so does the menu global. Give a global of your own the same display and it appears there too, not in the sidebar:

cms/globals/analytics.ts
export const analytics = defineGlobal({
  nav: { display: "settings", group: "Tracking", icon: "chart-line", order: 5 },
  fields: { plausibleDomain: { type: "text" } },
});
nav optionEffect on the Settings page
display"settings" lists the entry here instead of in the sidebar.
groupThe section the entry sits in. Default Site.
iconA Lucide icon name.
orderThe position, lowest first. general is 1, seo is 2.

See nav for all display values.