compost icon indicating copy to clipboard operation
compost copied to clipboard

How to use your theme

Open maddovr opened this issue 3 years ago • 19 comments

Hello and sorry to bother you with a noob question, but apparently recent versions of hugo do not really support the way you described in the readme to install the theme or maybe I'm doing something wrong. Could you please explain how to install and use your theme (possibly the tagged releases instead of the main branch) in detailed steps?

maddovr avatar Feb 06 '23 15:02 maddovr

Hi, could you please post the error you get when you run the command in step 2 in the README?

canstand avatar Feb 08 '23 15:02 canstand

Error: failed to get ["-d" "-u" "github.com/canstand/compost"]: failed to execute 'go [get -d -u github.com/canstand/compost]': failed to execute binary "go" with args [get -d -u github.com/canstand/compost]: go: go.mod file not found in current directory or any parent directory. This is what I get with latest hugo extended and copying the required snippet from your readme. I have to say I'm unfamiliar with hugo, my current blog is in jekyll but I would like to switch due to growing frustrations with jekyll, so I'm still a total noob at hugo.

maddovr avatar Feb 08 '23 21:02 maddovr

Because the theme uses the Hugo Modules feature, you need to install golang.

See https://gohugo.io/installation/linux/#prerequisites

Go is required to:

  • Use the Hugo Modules feature
  • Build Hugo from source

canstand avatar Feb 09 '23 00:02 canstand

I have golang installed already through scoop go version go1.20 windows/amd64 and the go binary is in PATH. I'm on windows and the error is still the same.

maddovr avatar Feb 10 '23 14:02 maddovr

Maybe you need to run hugo mod init first?

https://gohugo.io/commands/hugo_mod_init/

canstand avatar Feb 10 '23 15:02 canstand

I have the same issue. image

YuYoung32 avatar May 06 '23 15:05 YuYoung32

I got the same issue

I have the same issue. image

I got that too

ihsanpraditya avatar May 07 '23 00:05 ihsanpraditya

Two possible reasons to check:

  1. The screenshot shows a Windows system. Have you used Powershell as required?
    • See If you are a Windows user:.
    • By the way, there is no need to run the git submodule command, since this theme uses the Hugo Modules approach.
  2. The command go mod init is used to initialize your own project, so maybe follow the instructions in the official documentation here, run hugo mod init github.com/<your_user>/<your_project>.

canstand avatar May 07 '23 10:05 canstand

I got it to work.

This is the full step-by-step that should work for everyone from scratch:

scoop install go hugo-extended nodejs-lts

hugo new site mysite
cd ./mysite
hugo mod init mysite # this is the critical step I believe most of us missed!

Add-Content ./hugo.toml @'

theme = 'github.com/canstand/compost'

# required
[build]
_merge = 'deep'

# required
[markup]
_merge = 'deep'

# for better seo
[minify]
_merge = 'deep'
'@

hugo mod get -u
hugo mod npm pack
npm install

then when you run hugo serve or hugo server you will get a 3 errors like this:

execute of template failed: template: partials/analytics.html:1:15: executing "partials/analytics.html" at <.Site.IsServer>: can't evaluate field Site in type *page.siteWrapper

to fix this go to the partials/analytics.html file (the full path should be in the error message) and delete all of its content (just clear it out).

Then I had to run npm install one more time and then hugo serve and the site came up successfully!

jantari avatar Jul 30 '23 16:07 jantari

Just adding my own experience report. I did my best to follow the gist of this conversation and the README instructions using WSL2.

$ hugo new site hugotest
Congratulations! Your new Hugo site is created in /home/coder/workspace/hugotest/hugotest.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/ or
   create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".

Visit https://gohugo.io/ for quickstart guide and full documentation.
$ cd hugotest
$ ls
archetypes/  assets/  content/  data/  hugo.toml  layouts/  static/  themes/
$ hugo mod init hugotest
go: creating new go.mod: module hugotest
go: to add module requirements and sums:
        go mod tidy
$ # here, I inserted the required text into `hugo.toml`
$ hugo mod get -u
go: no module dependencies to download
go: downloading github.com/canstand/compost v0.6.0
go: added github.com/canstand/compost v0.6.0
hugo: collected modules in 1575 ms
$ hugo mod npm pack
$ npm install

added 134 packages, and audited 135 packages in 9s

27 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice
npm notice New minor version of npm available! 9.5.0 -> 9.8.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.8.1
npm notice Run npm install -g [email protected] to update!
npm notice
$ hugo serve
Watching for changes in /home/coder/workspace/hugotest/{archetypes,assets,content,data,layouts,package.hugo.json,package.json,static}
Watching for config changes in /home/coder/workspace/hugotest/hugo.toml, /home/coder/workspace/hugotest/go.mod
Start building sites …
hugo v0.117.0-b2f0696cad918fb61420a6aff173eb36662b406e linux/amd64 BuildDate=2023-08-07T12:49:48Z VendorInfo=gohugoio


                   | EN
-------------------+-----
  Pages            |  7
  Paginator pages  |  0
  Non-page files   |  0
  Static files     |  4
  Processed images |  0
  Aliases          |  0
  Sitemaps         |  1
  Cleaned          |  0

Built in 584 ms
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

hugo serve ended up presenting me with this:

image

And there were no error messages in the console. I really liked the demo I saw of this theme, but I wish it were easier to use. I'm not especially interested in troubleshooting this issue at the moment, just letting you know what I experienced before I go back to the theme library and look for another.

coder543 avatar Aug 28 '23 02:08 coder543

The config required for version v0.6.0 has add this:

# required
[module]
_merge = 'deep'

See https://github.com/canstand/compost#usage

There was an issue with the daily build of themes.gohugo.io not reflecting new releases and README from Compost.

canstand avatar Aug 28 '23 03:08 canstand

Yes, I had used that portion from the README here on GitHub. I’m really unsure what went wrong.

coder543 avatar Aug 28 '23 03:08 coder543

It is true that there is a issue with the css built when running hugo server for the first time in a new project.

After Ctrl+C, run hugo server again and refresh the page and it will be normal.

It is not yet known why.

canstand avatar Aug 28 '23 04:08 canstand

It's related to https://github.com/gohugoio/hugo/issues/11403, see the latest version of usage.

canstand avatar Aug 31 '23 03:08 canstand

@canstand, Is it possible to disable displaying Hugo Variables for the current page? image

I used the latest theme with hugo v0.121.2.

hkunzhe avatar Jan 21 '24 07:01 hkunzhe

It's only show when hugo server for develop, not in hugo build.

canstand avatar Jan 21 '24 07:01 canstand

It's only show when hugo server for develop, not in hugo build.

Thanks for your quick reply! I got it!

hkunzhe avatar Jan 21 '24 07:01 hkunzhe

Hugo newbie here āœ‹šŸ¼

I liked this theme and needed clarification about installing it because the README assumes I am familiar with Hugo, so I checked out this issue. For anyone looking for answers, here's a step-by-step to complete the setup:

  1. Make sure to have Go installed (for me on Mac: brew install go)
  2. Init mods in your project with your repo path: e.g., hugo mod init github.com/yourusername/yourproject
  3. Add theme = 'github.com/canstand/compost' to your hugo.toml file
  4. Paste the toml config info described in the README to your hugo.toml file
  5. Run the install commands described in the README
  6. Add node_modules and .hugo_build.lock to .gitignore

edmundito avatar Feb 18 '24 19:02 edmundito

Hugo newbie here āœ‹šŸ¼

I liked this theme and needed clarification about installing it because the README assumes I am familiar with Hugo, so I checked out this issue. For anyone looking for answers, here's a step-by-step to complete the setup:

  1. Make sure to have Go installed (for me on Mac: brew install go)
  2. Init mods in your project with your repo path: e.g., hugo mod init github.com/yourusername/yourproject
  3. Add theme = 'github.com/canstand/compost' to your hugo.toml file
  4. Paste the toml config info described in the README to your hugo.toml file
  5. Run the install commands described in the README
  6. Add node_modules and .hugo_build.lock to .gitignore

This saved my day!

I had to remove hugo.toml to use config.toml, as it is reading hugo.toml first.

ccnmxns avatar Jul 05 '24 09:07 ccnmxns