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.
| Global | Fields |
|---|---|
general | title, tagline, favicon |
seo | title 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.
falseremoves a global.settings: falseremoves all of them, also thetranslationsglobal 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>
<script setup lang="ts">
const { data: general } = await useTenon().getGlobal("general");
</script>
<template>
<footer v-if="general">
<strong>{{ general.title }}</strong>
<a v-if="general.phone" :href="`tel:${general.phone}`">{{ general.phone }}</a>
</footer>
</template>
import { createServerFn } from "@tanstack/react-start";
import cms from "../../tenon.config";
// Call it in a route's loader and pass the result to <Footer>.
export const getGeneral = createServerFn().handler(() => cms.getGlobal("general"));
export function Footer({ general }: { general: Awaited<ReturnType<typeof getGeneral>> }) {
return (
<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 option | Effect on the Settings page |
|---|---|
display | "settings" lists the entry here instead of in the sidebar. |
group | The section the entry sits in. Default Site. |
icon | A Lucide icon name. |
order | The position, lowest first. general is 1, seo is 2. |
See nav for all display values.