If you want any file to be processed by Hugo Pipes, for example compiling Sass stylesheets or converting TypeScript files to JavaScript, it needs to be in the assets/ directory.
assets/, but can be configured in config.tomlstaticDir which can take an array of values for multiple static directories, there can only be one assetDir1staticDir = ['assets', 'static']
2assetDir = 'assets/'
If you are creating or using a custom theme, the files in the themes asset directory themes/foo/assets will NOT be processed by Hugo pipes by default.
You can however mount multiple asset directories. Mounting a new directory means the default directory is ignored, so be sure to explicitly add it again if you want the default directory to work
1# config.toml
2[module]
3 [[module.mounts]]
4 source = 'assets'
5 target = 'assets'
6 [[module.mounts]]
7 source = 'themes/foo/assets'
8 target = 'assets'
Now, if you link to a resource with path css/custom.scss, it will look in both css/custom.scss and themes/amnastic/css/custom.scss
1{{ $scss_options := (dict "transpiler" "libsass" "outputStyle" "compressed") }}
2{{ $scss_file := resources.Get "css/custom.scss" }}
3{{ $customStyles := $scss_file | resources.ToCSS $scss_options | minify }}
4
5<link rel="stylesheet" href="{{ $customStyles.RelPermalink }}">
After the resources are processed, Hugo publishes them to the publishDir, which by default is public/. The link would look like this when compiled
1<link rel="stylesheet" href="/css/custom.min.css">
If a file needs to be loaded as a resource and processed by Hugo Pipes, it needs to be in assetDir location(s)
styles.scss, main.ts, images etc.assets/ in project basepublishDir after they have been processed, you can reference them with their relative URL which would be just the file name. For example: /styles.css instead of assets/styles.cssIf i file needs to be in the publishDir when the site is built, and does not need any processing or compiling, it needs to be in the staticDir
favicon.ico, robots.txt, manifest.json etc.static/ in project basestatic/ directory can be directly referenced by their relative URL. For example, the file at location static/manifest.json can be referenced anywhere in the site with the relative URL /manifest.json. Same as assetDir, no need to mention staticDir in the final URL