Custom Head, Analytics & Navigation

🕒 Reading time: 2 min📝 Words: 482👀 Views: Loading...

View Markdown source

head.yml — Analytics & Custom Head

File: stalux/config/head.yml

id: head
# googleAnalyticsId: "G-XXXXXXXXXX" # Google Analytics 4 tracking ID
# bingClarityId: "" # Microsoft Bing Clarity project ID
# umami:
# id: "" # Umami website ID
# url: "" # Umami script URL
anyhead: "" # Custom HTML injected into <head>

Analytics Tools

Tool Config Field Notes
Google Analytics googleAnalyticsId Format G-XXXXXXXXXX, theme auto-loads GA4
Microsoft Clarity bingClarityId Theme auto-loads Clarity tracking
Umami umami.id + umami.url Both id and url required
Custom snippets anyhead Arbitrary HTML (e.g., verification meta tags, custom fonts)

Microsoft Clarity setup

Set the Project ID from your Clarity project in head.yml:

id: head
bingClarityId: "YOUR_CLARITY_PROJECT_ID"

The field name is kept for compatibility with older Stalux configuration, while the product is now called Microsoft Clarity. In the Clarity console, open Settings → Setup → Get tracking code and use the Project ID for that project. Stalux injects the asynchronous loader into <head> for you; do not paste the same snippet into anyhead, Google Tag Manager, or another integration.

The Project ID is a public client-side identifier. It is not the Data Export API token. Keep Data Export tokens server-side and never place them in head.yml or browser code. To verify a deployed site, check that the generated https://www.clarity.ms/tag/<project-id> URL preserves the configured value and that Network shows https://www.clarity.ms/collect. The loader is guarded so Astro View Transitions do not add another Stalux loader.

If the host site has a strict CSP or needs cookie consent, configure those policies and consent signals at the host site. Stalux only loads the tracking code and does not make privacy or legal-compliance decisions.

File: stalux/config/navs.yml

id: navs
items:
- title: Home
icon: house
link: /
- title: Posts
icon: archive
link: /archives
# ... more items
Field Description
link Internal path or full external URL
icon Optional Lucide icon name, e.g. rocket or arrow-down-0-1.
Search button Built-in when Orama is enabled, does not need a nav item

Copy the name from the Lucide icon page into icon. Stalux renders it as an inline SVG in desktop and mobile navigation. Omit icon for a text-only link. An unknown name logs a warning and still renders the link. The older names home and wormhole continue to resolve to house and shell.

Common Operations

Operation How
Add analytics Set the tracking ID in head.yml, no script needed
Custom head HTML Use anyhead to inject <meta>, <style>, etc.
Add a nav item Append to items in navs.yml; external links need https:// prefix
Change favicon Set site.yml → favicon path