Appearance
Assets
CSS, JavaScript, images, and fonts bundled in your theme are served from the theme.asset route and referenced from templates with the theme_asset() function. The list of servable extensions below is generated from the app's ThemeAssetController.
Assets bundled in your theme are served from the theme.asset route and referenced from templates with the theme_asset() function.
Servable extensions
Text assets (served from the database, with ETag caching):
css, js, svg, json
Binary assets (served from the filesystem, immutable long-cache):
Any other extension returns 404.
Referencing assets
Put assets in their type directory (css/, js/, fonts/, images/) in your .zip; reference them by that path:
twig
<link rel="stylesheet" href="{{ theme_asset('css/app.css') }}">
<script src="{{ theme_asset('js/app.js') }}" defer></script>
<img src="{{ theme_asset('images/logo.svg') }}" alt="Logo">Tips
- Put assets in an
assets/directory grouped by type (assets/css/,assets/js/,assets/fonts/,assets/images/) and reference them by their inner path, e.g.theme_asset('css/app.css'). Top-level type directories (css/,js/, …) work too — both layouts produce the same paths. - The route only serves the extensions above; anything else returns
404. - Binary assets are cached immutably, so change the file name (or a path segment) when you ship new content rather than overwriting in place.