Modify resources RelPermalink

Hi,
first post :slight_smile:

I have a site with baseURL = "https://example.com/foo" structure. Injecting CSS via

{{- $vendor := resources.Get "scss/vendor.scss" | toCSS }}
{{- $app := resources.Get "scss/app.scss" | toCSS }}
{{- $style := slice $vendor $app | resources.Concat "css/main.css" | minify | fingerprint }}
<link rel="stylesheet" href="{{ $style.RelPermalink }}">

is working perfectly, CSS is located in /foo/css/.

Now, what I want to achieve is that with using hugo.IsProduction CSS is located in /css/.

According to https://gohugo.io/hugo-pipes/introduction/#asset-publishing " Assets will only be published (to /public ) if .Permalink or . is used."

I tried to use replaceRE on $style. but it replaces ALL occurrences. So after detecting first subfolder I want to replace, It replaces everything.

Any1 got a clue how to achieve that?

Cheers
midzer

1 Like

If I understand correctly that in production, you want the following structure:

example.com/foo/
example.com/css/main.css

Untested, but my first guess would be to try the following:

{{- $style := slice $vendor $app | resources.Concat "../css/main.css" | minify | fingerprint }
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.