Problem getting Hugo Pipes working with multiple languages

Hi, I just found out, that there’s a bug with the new sass pipeline when you’re using multiple languages (i18n). Either the sass files won’t compile into the correct directory or you won’t be able to get the correct URL for the compiled markup. For more information you can read this!

In the meantime I just figured out a over-complicated workaround, so you still can use the sass pipeline with multiple languages. So this is the code:

{{- $target := printf "%s/assets/css/main.css" .Lang }}
{{- $css := resources.Get "sass/main.sass" | toCSS (dict "targetPath" $target) | minify }}
<link rel="stylesheet" href="{{ .Site.BaseURL }}{{ print $css.RelPermalink | replaceRE "^/[a-z]{2}/(.*)" "$1" }}" media="screen" />

For this workaround you should put your sass files in the /assets/sass directory and it would compile into each language directory, such as /public/en/assets/css/main.min.css. Just adapt it to your likings.

Cheers!

Not sure to understand the problem here.
Following Hugo latest release, the assets are language agnostic which makes a lot of sense (very few people needs distincts assets per language but those who do can still process their assets using a distinct target path per language.

Regarding your issue, use .Permalink instead of .RelPermalink and every should go smooth.

I have a multilingual and didn’t even notice the latest release change, .Permalink would serve the right URL for me.

@bep I quote:

A software bug is an error, flaw, failure or fault in a computer program or system that causes it to produce an incorrect or unexpected result, or to behave in unintended ways.
(Source: Wikipedia)

Expected and actual result of the sass pipeline without languages:
/assets/sass/main.sass/public/assets/css/main.css

Expected result of the sass pipeline with languages:
/assets/sass/main.sass/public/en/assets/css/main.css

Actual result of the sass pipeline with languages:
/assets/sass/main.sass/public/assets/css/main.css

Therefore:

$has_bug = (expected_result !== actual_result);

:smirk: :joy:

So, what’s the problem? This is a bug by definition.

@regis Now the headline is misleading. This is a bug and I found a workaround. :smirk:

Cheers!

OK, then we don’t agree. And that is fine.

1 Like

Ok, so what I had a hard time understanding from @mirkoschubert here (the attitude did not help) is that the issue reported only applies to multilingual websites configured with mutli domains.

In this particular case where public is split into two distinct directories, the assets are only published to the default language directory.
This is my personal opinion that, in a multi-domain configuration, assets, like static files, should be published in both directories.

In the mean time, there’s always the workaround shared above.

@mirkoschubert, despite your smileys, your tone and attitude both in GH and in here made it very difficult to pinpoint a problem you were not able to clearly identify yourself.
Next time, go away with the smirkeys, understand nothing is granted, and try to understand thoroughly the issue at hand before bringing it up here and claiming a fix is due.

4 Likes