Bootstrap and hugo setup

I’m new to Hugo and having trouble setting up Hugo with bootstrap. I want to be able to compile bootstraps SCSS with my css then minify, and combine bootstrap JS with my js. Currently, my website is a single page and I use gulp to join css and min, and join js and min.

I followed the directions from:
GitHub - gohugoio/hugo-mod-bootstrap-scss: Packages Bootstrap SCSS (v4 and v5) as a Hugo Module
Working example of Hugo Modules and Bootstrap .scss files? - #4 by stephenpiscura

When I execute:

mkdir hugo
cd hugo
wget … /v0.111.3/hugo_extended_0.111.3_Linux-64bit.tar.gz
tar xf hugo_extended_0.111.3_Linux-64bit.tar.gz

./hugo new site example_dot_com
cd example_dot_com
…/hugo new theme testTheme

gedit config.toml &
#add
[module]
[[module.imports]]
path = “githubcom/twbs/bootstrap” #note replace . with due to posting issues
[[module.imports.mounts]]
source = “scss”
target = “assets/scss/bootstrap”

…/hugo mod init

I get the error that bootstrap does not exist

WARN 2023/05/09 10:45:32 module “github com/twbs/bootstrap” not found; either add it as a Hugo Module or store it in “/hugo/example_dot_com/themes”.: module does not exist
go: cannot determine module path for source directory /hugo/example_dot_com (outside GOPATH, module path must be specified)

Example usage:
‘go mod init examplecom/m’ to initialize a v0 or v1 module
‘go mod init examplecom/m/v2’ to initialize a v2 module

Run ‘go help mod init’ for more information.
Error: failed to init modules: failed to execute ‘go [mod init ]’: failed to execute binary “go” with args [mod init ]: go: cannot determine module path for source directory /home/brian/stellar_patent_website/hugo/example_dot_com (outside GOPATH, module path must be specified)

Example usage:
‘go mod init XXX’ to initialize a v0 or v1 module
‘go mod init XXX’ to initialize a v2 module

Run ‘go help mod init’

How do setup Hugo for bootstrap with scss?

Did you install Git and Go?
https://gohugo.io/installation/linux/#prerequisites

Did you initialize your project as a Hugo module?

hugo new site foo
cd foo
git init
hugo mod init foo    # Did you do this?

Use Hugo’s built-in tools instead:
https://gohugo.io/hugo-pipes/

Working example:

git clone --single-branch -b hugo-forum-topic-44286 https://github.com/jmooring/hugo-testing hugo-forum-topic-44286
cd hugo-forum-topic-44286
hugo server

@ jmooring

I have git and go installed:
go version → go version go1.18.10 linux/amd64
git --version → git version 2.31.1

If I mirror your code, I still get the same error:
./hugo new site example_dot_com
cd example_dot_com
…/hugo new theme testTheme

gedit config.toml &
[module]
[[module.imports]]
path = “github com/twbs/bootstrap”
[[module.imports.mounts]]
source = “scss”
target = “assets/scss/bootstrap”

git init
…/hugo mod init example_dot_com

I get the error:
WARN 2023/05/09 15:05:36 module “github com/twbs/bootstrap” not found;

Not sure what that means. Did you do this, as I suggested?

git clone --single-branch -b hugo-forum-topic-44286 https://github.com/jmooring/hugo-testing hugo-forum-topic-44286
cd hugo-forum-topic-44286
hugo server

@jmooring
By mirroring, I mean I modified my code to match your suggestions.

I’m confused about doing the git clone. I need to start with a blank state so I can put in my website.

Well, if you didn’t clone the example site, then I’m not sure how you would match my suggestions.

@jmooring
I stopped when I got a warning about not being able to find bootstrap. Cloning your github repo doesn’t help me solve my problem of setting up a new website. I first tried to setup a hugo with gohugoio/hugo-mod-bootstrap-scss/v5 and I could not get it working. What are the tests you used to create the github lib?

That is false.

ok i’ll help you … mmmm … sorry. I was wrong

@prusikknot, we request you to refrain from using abusive language like this. Joe Mooring is not only one of the revered member of this forum but also one of the core maintainers of the Hugo project. He is known for providing high quality, detailed answers to questions posted by people here.

We hope you have gone through the Code of Conduct, which says:

Finally, this is a positive and friendly community, and as with other open source projects, the Hugo project runs on unpaid volunteer work. Please be reminded of a couple of rules to make things easier in the forum:

  • Keep it civil, courteous and polite. No personal or ad hominem attacks.

More importantly, it says that:

We haven’t had to do it very often, but, we reserve the right to ban or suspend from this community anyone who cannot play by the rules. Thanks for your understanding and cooperation.

You should be grateful to him since, he has chosen to help you out. In case you don’t like what this forum has to offer you, you may visit Stack Overflow, Reddit or any other platform.

In case you didn’t understand how something suggested by him can help you, feel free to seek clarifications. If instead, you choose to use impolite, rude language, you can be certain that people are not likely to help you.

1 Like