Hugo theme code to include custom CSS files

You can use the following code in your Hugo theme to include a range of custom CSS files.

You need to include it somewhere in the HTML <head>. In my theme tailbliss, it can be added to the end of layouts/partials/head.html:

{{ range .Site.Params.custom_css -}}
<link rel="stylesheet" href="{{ (resources.Get . | postCSS).RelPermalink }}">
{{- end }}

Now you can configure a list of custom CSS files in hugo.yaml:

params:
  custom_css:
    - 'css/techoverflow.css'