Skip to content

Hugo server does not apply changes made to resources included via resources.Get in shortcodes #7960

@mfg92

Description

@mfg92

I have a shortcode that uses resources.Get to load a CSS file to incude it. I use that shortcode in a markdown page.
When I start hugo server (./hugo.exe server -D --disableFastRender --gc --bind 0.0.0.0) the shortcode works as expected and all is styled correctly.

Now to the problem: When I change the mentioned CSS file, hugo server detects the change and reloades the browser tab. But the style change is not there.
If, for instance, I change the color of something in the CSS file, the color is not changed after the reload. But if I stop hugo server and start it again, the color changes.

Example shortcode to demonstrate the problem:

project_root/layouts/shortcodes/test.html:

<link rel="stylesheet" href="{{ (resources.Get "test.css").RelPermalink }}" media="screen">

<hr>

project_root/assets/test.css:

hr {
    width: 100%;
    color: #F00;
}

some markdown file:

...
{{< test >}}
...

I'm using Hugo version 0.78.2 on Windows 10.

Here you can find the real life shortcode project: https://github.com/mfg92/hugo-shortcode-gallery/blob/865699e9f33637655a701fb811bc20225befce7c/layouts/shortcodes/gallery.html#L71

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions