Docs menu

Getting started

IntroductionInstallationProject structure

Building pages

RoutingPagesLayoutsStylingMarkdownContent and dataIslands

Going live

SEO and headDeployingForms

Guides

Build a brochure site

Advanced

Running as a server

Reference

Reference

Going live

SEO and head

Titles, social sharing, canonical links, structured data, sitemap.xml and robots.txt.

imba-pages writes each page's <head> from its meta: the site's defaults in src/site.imba, with the page's own meta merged on top.

# src/site.imba
export const url = 'https://acme.example'

export const meta =
	title: 'Acme Studio'
	siteName: 'Acme Studio'
	description: 'Design and development for small businesses.'
	lang: 'en-GB'
	locale: 'en_GB'
	image: '/images/share.png'
	imageAlt: 'The Acme Studio logo'

Meta keys

Key Becomes
title <title> and og:title
description <meta name="description"> and og:description
image og:image, the preview when a link is shared (1200 × 630 works best), plus a large Twitter/X card
imageAlt og:image:alt
siteName og:site_name
type og:type: website by default, article for a post
locale og:locale, e.g. en_GB
lang <html lang>
noindex yes keeps the page out of search results and the sitemap
canonical A different canonical address, or no for none
sitemap no leaves the page out of the sitemap (it can still be indexed)
jsonld Structured data (an object or a list), written as <script type="application/ld+json">

The 404 page is noindex automatically. Use noindex: yes for anything else that shouldn't be found, like a form's thank-you page.

The site address

export const url turns on:

  • a canonical link and og:url on every page, with its full address;
  • full URLs for relative image paths (social networks need those);
  • /sitemap.xml: every page without noindex or sitemap: no;
  • /robots.txt: allows everything and points to the sitemap.

Both files are served in dev too. A robots.txt or sitemap.xml in public/ replaces the generated one.

If your host redirects /about to /about/ (Cloudflare Pages does), add export const trailingSlash = yes so canonical links and the sitemap use the final address.

Structured data

Helps search engines show a business's details. Put site-wide data in the site meta; a page that sets its own jsonld replaces it (use a list for several):

export const meta =
	jsonld:
		'@context': 'https://schema.org'
		'@type': 'LocalBusiness'
		name: 'Acme Studio'
		telephone: '0117 496 0000'

Adding your own tags

head returns extra tags for every page:

export def head ctx
	[
		<link rel='icon' href='/favicon.svg'>
		<meta name='theme-color' content='#ffffff'>
		<link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Inter&display=swap'>
	]

ctx has meta, path, url (the page's canonical address, or null) and absolute(path), which turns a path into a full URL. That's enough for hreflang links between languages, or analytics.

Writing the whole head yourself

export const defaultHead = no turns off every tag in the table above. Pages then get only the charset, viewport, <title>, stylesheet, and whatever head returns.