Hugo 检测到 css 更改但输出没有更改

stk*_*flw 5 sass hugo

我正在使用 Hugo 构建一个网页。

\n\n

这是我的网站标题:

\n\n
<!DOCTYPE html>\n<html lang="en">\n  <head>\n    <meta charset="UTF-8" />\n    <title>Website</title>\n    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0" /> -->\n    <meta name="referrer" content="no-referrer" />\n    <link rel="icon" href="/img/favicon.ico" type="image/x-icon" />\n    <link\n      rel="stylesheet"\n      href="https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.2/tiny-slider.css"\n    />\n\n    <!-- tried this as per suggestion from Hugo forums\n    {{ $sassIncludes := (slice "node_modules" "assets/scss/vendor" "assets/scss/components") }}\n    {{ $target := "styles/main.css" }}\n    {{ if .Site.IsServer }}\n        {{ $cssOpts := (dict "targetPath" $target "enableSourceMap" true "includePaths" $sassIncludes ) }}\n        {{ $styles := resources.Get "/css/main.scss" | toCSS $cssOpts }}\n        <link rel="stylesheet" href="{{ $styles.Permalink }}" media="screen">\n    {{ else }}\n        {{ $cssOpts := (dict "targetPath" $target "includePaths" $sassIncludes ) }}\n        {{ $styles := resources.Get "/css/main.scss" | toCSS $cssOpts | postCSS | minify | fingerprint }}\n        <link rel="stylesheet" href="{{ $styles.Permalink }}" integrity="{{ $styles.Data.Integrity }}" media="screen">\n    {{ end }} -->\n\n    {{ $style := resources.Get "/css/main.scss" | resources.ToCSS | minify | fingerprint}}\n\n    <link rel="stylesheet" href="{{ $style.RelPermalink }}"/>\n  </head>\n\n  <body>\n    <header>\n      <div class="nav-bar">\n        <a class="top-logo" href="/">\n          <img src="/img/logo.svg" />\n        </a>\n    </header>\n  </body>\n</html>\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是main.scss:

\n\n
@import \'reset\';\n@import \'commonStyles\';\n@import \'pricing\';\n@import \'docs\';\n@import \'header\';\n@import \'footer\';\n@import \'home\';\n\nheader {\n  .nav-bar {\n    background-color: red;\n  }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

配置.toml:

\n\n
baseURL = "http://example.org/"\nlanguageCode = "en-us"\ntitle = "Website"\nassetDir = "static"\n
Run Code Online (Sandbox Code Playgroud)\n\n

我正在 macOS 上使用hugo server命令运行。我正在更改样式中的背景颜色。这是终端输出:

\n\n
thatsme/../website-landing (master\xe2\x86\x911|\xe2\x9c\x9a7\xe2\x80\xa6) % hugo server                                        \nBuilding sites \xe2\x80\xa6 WARN 2020/05/18 12:27:34 found no layout file for "HTML" for kind "taxonomyTerm": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.\nWARN 2020/05/18 12:27:34 found no layout file for "HTML" for kind "taxonomyTerm": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.\n\n                   | EN  \n-------------------+-----\n  Pages            | 14  \n  Paginator pages  |  0  \n  Non-page files   |  0  \n  Static files     | 19  \n  Processed images |  0  \n  Aliases          |  0  \n  Sitemaps         |  1  \n  Cleaned          |  0  \n\nBuilt in 17 ms\nWatching for changes in /Users/thatsme/git/website-landing/{archetypes,content,data,layouts,static}\nWatching for config changes in /Users/thatsme/git/website-landing/config.toml\nEnvironment: "development"\nServing pages from memory\nRunning in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender\nWeb Server is available at http://localhost:1313/ (bind address 127.0.0.1)\nPress Ctrl+C to stop\n\nChange of Static files detected, rebuilding site.\n2020-05-18 12:27:42.202 +0200\nSyncing css/main.scss to /\n
Run Code Online (Sandbox Code Playgroud)\n\n

仅当我重新启动服务器时,样式更改才适用。Html 更改已得到正确应用。

\n

小智 1

以下命令应该可以解决问题:

hugo serve --noHTTPCache --ignoreCache --disableFastRender
Run Code Online (Sandbox Code Playgroud)