Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prism modules aren't loaded correctly when using subdirectory #281

Open
Valhrafnaz opened this issue Jul 2, 2024 · 5 comments
Open

prism modules aren't loaded correctly when using subdirectory #281

Valhrafnaz opened this issue Jul 2, 2024 · 5 comments

Comments

@Valhrafnaz
Copy link

I host my blog at a sub-directory of my overall site, but sadly the theme seems to have misconfigured paths, as adding a subfolder to my baseURL causes the build process to fail thusly:

Error: error building site: POSTCSS: failed to transform "css/non-critical.css" (text/css): CssSyntaxError: postcss-import: /home/valhrafnaz/blog-server/stdin:13:5: Failed to find 'blog/prismjs/plugins/toolbar/prism-toolbar.css'
  in [
    /home/valhrafnaz/blog-server,
    /home/valhrafnaz/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/schnerring/hugo-theme-gruvbox@v0.0.0-20240621140605-37cea91b04c5/assets/css
  ]

  11 |     
  12 |     /* Import stylesheet for Prism plugin 'toolbar' from 'blog/prismjs/plugins/toolbar/prism-toolbar.css' */
> 13 |     @import "blog/prismjs/plugins/toolbar/prism-toolbar.css";
     |     ^
  14 |   
  15 | 

I assume this is caused by using the absolute path rather than the relative path to load the plugins. Removing the /blog from my baseURL causes the build to go without a hitch, but this of course breaks all links since they now missing the sub-directory.

@schnerring
Copy link
Owner

schnerring commented Jul 4, 2024

Have you looked at the hugo -s CLI argument?

-s, --source string              filesystem path to read files relative from

I think you need to run hugo -s blog/

See:

@Valhrafnaz
Copy link
Author

Sadly that does not seem to fix the issue whatsoever. Using -s ~/blog/ (the directory which contains the site files) produces the exact same error, which is expected, since that is the directory from which the command is run. The only way avoid this issue seems to be to change the baseURL to an incorrect value as mentioned in the issue. Renaming the build folder to something else (jic there is some weird interaction if the subdir and build folder are named the same) also does not help.

@Valhrafnaz
Copy link
Author

I think I have found the fix. Using hugo -v reveals that the resources.postCSS call in layouts/partial/head/stylesheets.html is deprecated. Cloning the repo, replacing said call with the recommended css.postCSS has fixed the issue for me. I don't really have capacity to test this, but on my end this does not seem to produce any other negative side effects.

@wesgould
Copy link

I have this same issue. I am guessing it has to do with one of the newer versions of hugo. It works find on my linux machine runninghugo v0.92.2+extended linux/amd64 BuildDate=2023-01-31T11:11:57Z

On my mac running v0.132.1+extended darwin/arm64 I get the error.

I ran a nix flake with v0.132.1+extended on my linux machine and encountered the same issue.

I'll keep digging when I have time, but hopefully that helps someone smarter than me to narrow down what the problem could be.

@schnerring
Copy link
Owner

Cloning the repo, replacing said call with the recommended css.postCSS has fixed the issue for me.

Thanks for investigating. I bumped the minimum Hugo version to 0.128.0. That's the version where resources.PostCSS was deprecated in favor of css.PostCSS. I changed the code accordingly as per your suggestion.

Maybe you could give it another try since I can't reproduce the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants