Skip to main content
this section: |

Site styling

~3 m

site.css

Create assets/css/site.css and put your site-specific CSS tweaks in it.

It is loaded last — after picnic, the theme bundle and the icon font — so anything in it wins over the theme on equal specificity. In production it is minified, fingerprinted and given an SRI hash, which means it can be cached forever and you can comment it as freely as you like: the comments never reach the browser. Under hugo server it is served untouched so it stays readable in devtools.

1
2
3
assets/
└── css/
    └── site.css      <- your overrides

Moving from static/site.css

Earlier versions of pihuw looked for static/site.css, and that still works — nothing breaks if you leave it there. It is simply served as-is, with no minification and no fingerprint, so it cannot be cached across deploys.

To upgrade, move the file:

1
mkdir -p assets/css && git mv static/site.css assets/css/site.css

If assets/css/site.css exists it always wins; static/site.css is only used as a fallback. pihuw logs a one-line warning when it falls back. To keep the file where it is and silence the warning, add this to your site config:

1
2
ignoreLogs:
  - pihuw-site-css-static

Web fonts

The theme already serves two faces from its own /webfonts/, with no CDN: Atkinson Hyperlegible for body text and Raleway 500 for headings, the page title, the nav and buttons. To keep them, do nothing. To swap one, redefine its token in site.css:

1
2
3
4
5
:root {
  --font-body:           "Georgia", serif;
  --font-heading:        "Raleway", sans-serif;
  --font-heading-weight: 700;
}

A face you no longer name is never downloaded. To bring in a different web font, either add its woff2 files and an @font-face to your site (no third party, the theme’s own approach), or load it from a font service as below.

Do not @import a font stylesheet at the top of site.css. An @import cannot start downloading until the importing stylesheet has itself arrived and been parsed, which serialises two round trips before any text can paint. Use a real <link> in layouts/_partials/hook/head-end.html instead:

1
2
3
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=...&display=swap">

Then redeclare --font-body, --font-heading, --font-narrow or --font-mono in your site.css. A font service sees every visitor’s IP address: say so in your privacy policy.

Overriding the theme’s own CSS

The colour system is described in css . Prefer redefining the tokens from site.css: that survives every theme upgrade untouched.

If you need more, the theme’s CSS is a directory of small files (assets/css/pihuw/*.css), not one monolith. You can replace any single one by putting a file of the same name in your own assets/css/pihuw/ — your copy wins and keeps the theme’s cascade position. That copy stops receiving theme updates for that component, so reach for it only when a token or a site.css rule will not do.

Hiding the theme toggle

If your site.css forces a single theme, the light/dark/system button is a control that does nothing. Turn it off in params.yaml:

1
2
3
ui:
  hide:
    themeToggle: true

This removes the button and stops theme-toggle.js being shipped at all — it is not merely hidden with CSS. theme-init.js still runs, so nothing else about theming changes.

ui.page.bodyClass