Issue with Loading Hugo Module for Theme

Description: I’m encountering an issue with loading a Hugo module for my theme. Despite following the recommended steps, I keep getting an error indicating that the module is not found. Here are the details of my setup and the steps I’ve taken:

Steps to Reproduce:

  1. Project Structure:
  • My Hugo site is located at website.
  • The theme I’m trying to use is referenced as a Hugo module.
  1. Configuration (config.yaml):

module:
imports:
- path: git.com/path/to/your/theme
theme: “your_theme_name”

  1. Commands Executed:
  • hugo mod tidy
  • hugo mod get -u

Error Message:

Error: failed to load modules: module “your_theme_name” not found in “/Users/pon-16234/web/my_website/website/themes/your_theme_name”; either add it as a Hugo Module or store it in “/Users/pon-16234/web/my_website/website/themes”.: module does not exist

Error: failed to load modules: module “your_theme_name” not found in “/Users/pon/web/my_website/website/themes/your_theme_name”; either add it as a Hugo Module or store it in “/Users/pon/web/my_website/website/themes”.: module does not exist

Additional Information:

  • I have verified that the repository URL is correct and accessible.
  • I have tried manually cloning the theme into the themes directory, but I would prefer to use Hugo Modules for better dependency management.

Request: Could someone please help me identify what might be going wrong and how I can resolve this issue? Any guidance or suggestions would be greatly appreciated.

Thank you!

first some comments:

  • please wrap code in ``` or use the </> button
    especially with yaml indentation is important
  • no links to your sources in the post
    so no detailed analysis possible
  • the preferred config file name would be hugo.yaml these days
  • did you initialize your site as a module?
  • usually the theme url starts with github.com
  • don’t use theme: your_theme_name if you are using modules

if all is really set up properly as it should be it works great

try this and if it fails

  • you’ll need to provide real code and config
  • output of hugo version
initialize
mkdir mysite
cd mysite
go mod init mysite.com/mysite
config.yaml
baseURL: https://example.org/
languageCode: en-us
title: My Site

module:
  imports:
    - path: github.com/frjo/hugo-theme-zen/v4
execute
hugo mod get -u
# go: no module dependencies to download
# go: added github.com/frjo/hugo-theme-zen/v4 v4.2.0
# hugo: collected modules in 1037 ms
hugo server
# ...
# Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
# Press Ctrl+C to stop

You need to remove the above line. There’s a longer explanation here, but I suggest you start with that.