An Astro theme’s config lives in two places. The production URL goes in site in astro.config.mjs, because canonical tags, the sitemap and RSS all build absolute URLs from it. The site name, description, contact email and social links go in the theme’s own settings file, usually src/config.ts, src/site.config.ts or src/data/site.ts.
Key Takeaways
- Set
sitefirst; without it, sitemaps and canonical URLs are wrong or missing.- Brand values (name, description, socials) belong in one settings file the whole theme imports.
- Read
siteback withAstro.siteinstead of hard-coding the domain again.- Search for the demo brand name and demo domain after editing to catch leftovers.
- Secrets never go in the settings file; use environment variables.
Set the site URL in astro.config.mjs
// astro.config.mjs
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
export default defineConfig({
site: 'https://www.example.com',
trailingSlash: 'always',
integrations: [sitemap()],
});
Use the exact production origin, including www if that is the version you serve, and no path. If you deploy under a subpath (common on GitHub Pages project sites), set base as well; our GitHub Pages guide covers that case. The Astro config docs list the other options themes usually set.
Leave trailingSlash as the theme shipped it unless you have a reason to change it, because the theme’s internal links were written to match.
Edit the theme settings file
Most themes collect brand values in one exported object. Find it by searching for the demo name you see in the header:
# Terminal
grep -rln "Northwind Studio" src/
Then edit it:
// src/config.ts
export const SITE = {
name: 'Harbour Dental',
title: 'Harbour Dental | Family dentist in Leeds',
description: 'Check-ups, hygiene and emergency appointments for the whole family.',
email: '[email protected]',
phone: '+44 113 000 0000',
locale: 'en-GB',
ogImage: '/og-default.jpg',
social: {
instagram: '',
linkedin: 'https://www.linkedin.com/company/example',
github: '',
},
} as const;
Keep the keys the theme already uses; components import them by name. If you do not use a network, set it to an empty string rather than deleting the key, then check how the footer handles empty values. Well-built themes skip empty links:
---
// src/components/SocialLinks.astro
import { SITE } from '../config';
const links = Object.entries(SITE.social).filter(([, url]) => url);
---
<ul class="social">
{links.map(([name, url]) => (
<li><a href={url} rel="me noopener">{name}</a></li>
))}
</ul>
If the footer renders empty icons instead, add a filter like the one above.
Use Astro.site instead of repeating the domain
Anywhere a component needs an absolute URL, build it from Astro.site so the domain stays in astro.config.mjs only:
---
// src/components/BaseHead.astro
import { SITE } from '../config';
const canonical = new URL(Astro.url.pathname, Astro.site);
const ogImage = new URL(SITE.ogImage, Astro.site);
---
<title>{SITE.title}</title>
<meta name="description" content={SITE.description} />
<link rel="canonical" href={canonical} />
<meta property="og:image" content={ogImage} />
Astro.site is undefined when site is not set, which is one more reason to set it first. The canonical URLs tip explains the edge cases.
Find the demo values you missed
Theme demos repeat the brand in places a settings file cannot reach: legal pages, structured data, public/manifest.webmanifest, public/robots.txt and image alt text. Search for both the demo name and the demo domain:
# Terminal
grep -rni "northwind\|demo-domain.com" src/ public/ astro.config.mjs
Then build and search the output, which also catches values that come from content files:
# Terminal
npm run build && grep -rli "northwind" dist/ | head
API keys for forms or analytics belong in .env and import.meta.env, never in src/config.ts, because anything imported by a component can end up in the shipped HTML or JavaScript. The environment variables guide shows the typed astro:env setup.
Every Komal theme is a standard Astro 7 project, so these two files are where you start; if you have not picked one, browse Astro themes and check the settings in the live preview.
FAQ
Where is the config file in an Astro theme?
Astro’s own config is astro.config.mjs (or .ts) in the project root. Theme-specific settings such as the site name and social links are usually in src/config.ts, src/site.config.ts or a file in src/data/.
What should the site option be in Astro?
The full production origin, such as https://www.example.com, with no trailing path. Astro uses it for Astro.site, canonical URLs, the sitemap and RSS links.
How do I change the site title in an Astro theme?
Edit the name or title value in the theme’s settings file. If the title is still unchanged, search the project for the old title; some themes also set it in the base layout or per page.
Can I put API keys in the Astro theme config?
No. Use environment variables in .env and read them with astro:env or import.meta.env. Settings files are imported by components and can be bundled into public output.