Skip to content

Customization

import { Aside, Steps, Card, CardGrid, Tabs, TabItem } from ‘@astrojs/starlight/components’;

Customize your Astro Swiss Theme to match your brand and needs. This guide covers customization techniques that work with both the free starter theme and the paid version.

File: src/consts.ts

Edit your personal/business contact information:

src/consts.ts
export const AUTHOR_NAME = 'Your Name';
export const AUTHOR_EMAIL = 'your.email@example.com';
export const AUTHOR_PHONE = '+1 234 567 8900';
export const AUTHOR_LINKEDIN_LINK = 'https://www.linkedin.com/in/yourprofile/';

These constants are used throughout the site in components like ContactLink.astro and Header.astro.

File: src/i18n/ui.ts

All user-facing text that needs translation is stored here. Edit the translations for each language:

```typescript title="src/i18n/ui.ts" fr: { 'business.name': 'Votre Entreprise', 'business.tagline': 'Votre slogan ici', 'business.description': 'Description de votre entreprise...', } ``` ```typescript title="src/i18n/ui.ts" fr: { 'nav.home': 'Accueil', 'nav.work': 'Nos Réalisations', 'nav.about': 'À Propos', 'nav.contact': 'Contact', } ``` ```typescript title="src/i18n/ui.ts" fr: { 'site.title': 'Your Site Title | Tagline', 'site.description': 'Your site description for search engines', } ```

The BaseLayout.astro component handles SEO metadata. It uses translations from ui.ts:

src/layouts/BaseLayout.astro
---
const pageTitle = title || t("site.title");
const pageDescription = description || t("site.description");
---
<head>
<title>{pageTitle}</title>
<meta name="description" content={pageDescription} />
<meta property="og:title" content={pageTitle} />
<meta property="og:description" content={pageDescription} />
</head>

You can override these on individual pages:

---
import BaseLayout from '@/layouts/BaseLayout.astro';
---
<BaseLayout
title="Custom Page Title"
description="Custom page description"
>
<!-- Page content -->
</BaseLayout>

File: src/components/Header.astro

The header includes:

  • Logo/brand name
  • Navigation menu
  • Contact links (phone, email)
  • Language selector
  • Theme toggle

Customize the logo:

src/components/Header.astro
<a href="/" class="logo">
<!-- Replace with your logo image -->
<img src="/logo.svg" alt="Your Brand" />
<!-- Or use text -->
<span>{t('business.name')}</span>
</a>

Modify navigation items:

src/components/Header.astro
<nav>
<a href="#home">{t('nav.home')}</a>
<a href="#work">{t('nav.work')}</a>
<a href="#about">{t('nav.about')}</a>
<a href="#contact">{t('nav.contact')}</a>
<!-- Add new items -->
<a href="#services">{t('nav.services')}</a>
</nav>

File: src/components/ThemeToggle.astro

Switches between light and dark mode. The component uses localStorage to persist the user’s preference.

Customize icons:

src/components/ThemeToggle.astro
<button id="theme-toggle" aria-label={t('theme.toggle')}>
<Icon name="sun" class="light-icon" />
<Icon name="moon" class="dark-icon" />
</button>

Create a new file in src/pages/:

src/pages/about.astro
---
import BaseLayout from '@/layouts/BaseLayout.astro';
import Header from '@/components/Header.astro';
---
<BaseLayout title="About Us">
<Header />
<main>
<h1>About Us</h1>
<p>Your content here...</p>
</main>
</BaseLayout>

This page will be available at /about (for default language).

For i18n support, create the page in each language folder:

src/pages/
├── about.astro # French (default) - /about
└── de/
└── about.astro # German - /de/about

Each file uses the same structure but pulls translations from ui.ts:

src/pages/about.astro
---
import BaseLayout from '@/layouts/BaseLayout.astro';
import { useTranslations } from '@/i18n/utils';
const t = useTranslations(Astro.currentLocale);
---
<BaseLayout>
<h1>{t('about.title')}</h1>
<p>{t('about.description')}</p>
</BaseLayout>

Create dynamic routes using [param].astro:

src/pages/blog/[slug].astro
---
export async function getStaticPaths() {
return [
{ params: { slug: 'post-1' } },
{ params: { slug: 'post-2' } },
];
}
const { slug } = Astro.params;
---
<h1>Blog Post: {slug}</h1>

Location: src/assets/

Add images to this folder and import them in components:

---
import logo from '@/assets/logo.png';
import { Image } from 'astro:assets';
---
<Image src={logo} alt="Logo" width={200} height={100} />

For static images, use the public/ folder:

<img src="/images/photo.jpg" alt="Photo" />

Location: public/fonts/

The theme uses Poppins font. To add custom fonts:

  1. Add font files to public/fonts/

  2. Update src/styles/global.css:

    src/styles/global.css
    @font-face {
    font-family: "YourFont";
    src: url("/fonts/YourFont-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    }
    body {
    font-family: "YourFont", sans-serif;
    }

Location: public/favicon.svg

Replace this file with your own favicon. Supported formats:

  • .svg (recommended for scalability)
  • .ico
  • .png

Update the reference in BaseLayout.astro if using a different format:

src/layouts/BaseLayout.astro
<link rel="icon" type="image/png" href="/favicon.png" />

The theme uses Tabler Icons. To use an icon:

---
import Icon from '@tabler/icons/outline/mail.svg?component';
---
<Icon class="w-6 h-6" />

The theme includes these Starwind UI components:

ComponentLocationUsage
Buttonsrc/components/starwind/button.astroButtons with variants
Cardsrc/components/starwind/card.astroContent cards
Carouselsrc/components/starwind/carousel.astroImage/content carousel
Avatarsrc/components/starwind/avatar.astroUser avatars
Inputsrc/components/starwind/input.astroForm inputs
Labelsrc/components/starwind/label.astroForm labels
Textareasrc/components/starwind/textarea.astroMulti-line inputs
Separatorsrc/components/starwind/separator.astroHorizontal dividers
Dropdownsrc/components/starwind/dropdown.astroDropdown menus
---
import { Button } from '@/components/starwind/button';
import { Card } from '@/components/starwind/card';
---
<Card>
<h2>Card Title</h2>
<p>Card content</p>
<Button variant="primary">Click Me</Button>
</Card>

Install additional Starwind components:

Terminal window
npx starwind add [component-name]

Browse available components at starwind.dev.

Create reusable components in src/components/:

src/components/Feature.astro
---
interface Props {
title: string;
description: string;
icon?: string;
}
const { title, description, icon } = Astro.props;
---
<div class="feature">
{icon && <img src={icon} alt="" />}
<h3>{title}</h3>
<p>{description}</p>
</div>
<style>
.feature {
padding: 2rem;
border-radius: var(--radius);
background: var(--card);
}
</style>

Use in pages:

---
import Feature from '@/components/Feature.astro';
---
<Feature
title="Fast"
description="Lightning fast performance"
icon="/icons/speed.svg"
/>

  • ✅ Store language-agnostic data in consts.ts
  • ✅ Store translatable content in i18n/ui.ts
  • ✅ Keep components small and focused
  • ✅ Use layouts for shared structure
  • ✅ Organize assets by type (images, fonts, icons)
  • ✅ Use TypeScript interfaces for props
  • ✅ Provide sensible defaults
  • ✅ Make components reusable
  • ✅ Use CSS variables for theming
  • ✅ Follow Astro’s component conventions
  • ✅ Use PascalCase for components: Header.astro
  • ✅ Use kebab-case for pages: about-us.astro
  • ✅ Use lowercase for utilities: utils.ts

Learn about the styling system and design tokens.

Styling Guide →

Add employees, portfolio projects, and manage content.

Data Management →

Add support for more languages.

Adding Languages →