This guide walks through how to fully switch to Dart Sass for styling in a Hugo static site. This removes all dependency on deprecated LibSass and uses the recommended Dart Sass SCSS module system (@use, @forward).
- Hugo Extended version (
brew install hugo) - Dart Sass installed (
brew install sass/sass/sass) - A proper SCSS folder structure under
/assets/scss/
assets/
βββ scss/
βββ base/
β βββ _variables.scss
β βββ _typography.scss
β βββ _reset.scss
β βββ _utilities.scss
βββ components/
β βββ _navbar.scss
β βββ _footer.scss
β βββ _cards.scss
β βββ _hero.scss
βββ layout/
β βββ _grid.scss
βββ themes/
β βββ _darkmode.scss
β βββ _maverick.scss
βββ styles.scss
@use "scss/base/variables" as *;
@use "scss/base/reset";
@use "scss/base/typography";
@use "scss/base/utilities";
@use "scss/layout/grid";
@use "scss/components/navbar";
@use "scss/components/footer";
@use "scss/components/cards";
@use "scss/components/hero";
@use "scss/themes/darkmode";
@use "scss/themes/maverick";{{ $options := dict "transpiler" "dartsass" "targetPath" "css/main.css" "outputStyle" "compressed" }}
{{ $styles := resources.Get "scss/styles.scss" | toCSS $options | fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Integrity }}">
π‘ This inline option forces Hugo to use Dart Sass even if LibSass is still linked internally.
In config.toml or hugo.toml:
# REMOVE THIS:
#[markup.sass]
# useDartSass = true
# OPTIONAL (not necessary if using inline dict):
[params.sass]
transpiler = "dartsass"hugo envYou should see:
github.com/sass/dart-sass/compiler="1.89.2"
...
hugo server --cleanDestinationDir --ignoreCacheYou should now see your styles applied correctly using Dart Sass features like @use, @forward, @mixin, and SCSS scoping.
Originally built by @askeijaz using Pygments, Dart Sass, and Hugoβs resources pipeline.