Hugo giving theme error when I install a new theme

Viewed 1717

I am new to coding and web development and I recently started a web development course so I could create a website for an NGO for which I work. I was generally googling when I came across Hugo's web framework. I decided to install Hugo on Parrot OS. I installed Hugo using the following command on the terminal:

snap install hugo

After running the following code, Hugo installed and it worked successfully. I then decided to install a custom website theme from Hugo's website only. I came across the theme called "meghna-hugo".

I performed the following steps on the terminal:-

hugo new site mywebsite
cd mywebsite/themes

after entering the themes directory I git cloned the theme

git clone git@github.com:themefisher/meghna-hugo.git

After cloning the theme I entered the following command to enter the exampleSite folder of meghna-hugo

cd meghna-hugo/exampleSite

After entering this directory I cut and pasted all the things from the mentioned directory to the root directory of my website. After replacing all the files with the meghna-hugo files I decided to start the hugo server locally

hugo server

But after running the Hugo command I encountered this error

Error: module "meghna-hugo" not found; either add it as a Hugo Module or store it in "/home".: module does not exist

I used the following websites for user friendly instructions as they were easy to follow and understand https://oxforditaliansociety.org/blog/installation/ and https://www.youtube.com/watch?v=lKT-tztvIEU

2 Answers

Did you set up your config file for Hugo to include your chosen theme?

Generally, you have to add something like theme = "THEME_DIRECTORY_NAME" to your config.toml

So in your case:

theme = "meghna-hugo"

This is found on the Hugo Docs - Quick Start, as well as, your theme docs

I had the same problem. The themeDir variable is not properly set in the config.toml file. It reads "../..", it should be the themes directory instead. Change it to:

themesDir = "themes"

This worked great for me.

Related