Full Step-by-Step Guide of Install Hugo Using Chocolatey & PowerShell

Posted by

Table of Contents

This guide will help you

✅ Install Chocolatey using PowerShell
✅ Install Hugo using PowerShell
✅ Create a Hugo Website
✅ Run & Build Your Hugo Website

🔹 Step 1: Open PowerShell as Administrator

  1. Press Win + X and select Windows Terminal (Admin).
  2. If you don’t see “Windows Terminal,” search for PowerShell, right-click, and select Run as Administrator.
  3. Type the following command to check if execution policies allow scripts to run: Get-ExecutionPolicy
  4. If it returns Restricted, change it using: Set-ExecutionPolicy Bypass -Scope Process -Force

🔹 Step 2: Install Chocolatey Using PowerShell

Run the following command in PowerShell (Admin):

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

After installation, verify Chocolatey is installed by running:

choco -?

If you see a list of commands, Chocolatey is installed successfully! ✅

🔹 Step 3: Install Hugo Using Chocolatey

Run this command in PowerShell to install Hugo Extended:

choco install hugo-extended -y

After installation, verify Hugo by running:

hugo version

If it displays the Hugo version, you’re good to go! ✅

🔹 Step 4: Create a Hugo Website

Now, let’s create your first website:

  1. Navigate to a directory where you want to create the website (e.g., Documents folder): cd C:\Users\YourUsername\Documents
  2. Create a new Hugo site: hugo new site mywebsite
  3. Move into the site folder: cd mywebsite

🔹 Step 5: Install a Hugo Theme

Choose a theme from Hugo Themes. For this example, we’ll use the Ananke theme:

  1. Initialize a Git repository and install the theme: git init git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
  2. Set the theme in the config.toml file: notepad config.toml
  3. Add this line at the top: theme = "ananke"
  4. Save and close the file.

🔹 Step 6: Add Content to Your Website

Create a new post:

hugo new posts/my-first-post.md

Edit the post:

notepad content/posts/my-first-post.md

Add some content inside the file, then save and close.

🔹 Step 7: Run the Hugo Server Locally

Start the Hugo server:

hugo server -D

The -D flag ensures that draft posts are visible.

Open your browser and go to:

http://localhost:1313

🎉 You should see your website running locally!

🔹 Step 8: Build Your Hugo Website

Once your website is ready, generate the final static site files:

hugo

This will create a public/ folder with all static files.

🔹 Step 9: Deploy Your Website Online

Option 1: Deploy to GitHub Pages

Follow the Hugo GitHub Pages Deployment Guide.

Option 2: Deploy to Netlify (Easiest)

Drag and drop your public/ folder onto Netlify.

Option 3: Deploy to Any Web Hosting

Upload the public/ folder to any web hosting service.

🎉 Final Summary

✅ Installed Chocolatey Using PowerShell
✅ Installed Hugo Using PowerShell
✅ Created a Hugo Website
✅ Installed and Applied a Theme
✅ Added Content to the Website
✅ Previewed the Website Locally
✅ Built and Deployed the Website

💡 Now your Hugo website is ready! 🚀

Here, you can face some issues so I am letting you know about these issues.

a. Error message “The term ‘git’ is not recognized” means that Git is not installed or not added to the system PATH on your Windows machine.

✅ Solution: Install Git and Add It to PATH

Step 1: Install Git

Since you are using PowerShell, let’s install Git using Chocolatey:

  1. Open PowerShell as Administrator
    • Press Win + X, then select Windows Terminal (Admin)
    • Or search for PowerShell, right-click, and Run as Administrator.
  2. Install Git using Chocolatey choco install git -y
  3. Wait for the installation to complete. It may take a minute.
  4. Verify Git Installation git --version If you see an output like git version 2.x.x, then Git is installed successfully.

Step 2: Add Git to System PATH (If Not Recognized)

If the git command is still not recognized, follow these steps:

  1. Find Git Installation Path Get-Command git | Select-Object -ExpandProperty Source This will show something like: C:\Program Files\Git\cmd\git.exe
  2. Manually Add Git to PATH
    • Open File Explorer and navigate to: C:\Program Files\Git\cmd
    • Copy this path.
    • Right-click on “This PC” → Select Properties → Click Advanced system settings.
    • Under the Advanced tab, click Environment Variables.
    • In the System Variables section, find Path and click Edit.
    • Click New and paste the copied path (C:\Program Files\Git\cmd).
    • Click OK to save changes.
  3. Restart PowerShell and try running: git --version

Step 3: Retry the Hugo Theme Installation

Once Git is installed and working, try running the theme installation command again:

git init
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke

Final Summary

✅ Installed Git using Chocolatey
✅ Verified Git installation
✅ Added Git to System PATH
✅ Successfully ran Hugo theme installation

Now, you should be able to proceed with your Hugo website setup. Let me know if you face any more issues! 🚀😊

b. Since you’ve installed Git using Chocolatey but it’s still not recognized, it means that the system PATH is not updated yet. Follow these steps to fix it:

✅ Step 1: Verify Git Installation

  1. Open PowerShell (as Administrator) and run: Get-Command git | Select-Object -ExpandProperty Source If it returns an error, Git is not installed correctly. In that case, manually install it (see Step 2).

✅ Step 2: Manually Install Git (If Chocolatey Install Didn’t Work)

If git --version is still not working, manually download and install Git:

  1. Open your web browser and go to:
    👉 Git for Windows Download
  2. Download the 64-bit version.
  3. Run the installer and follow the default installation steps (just keep clicking “Next”).
  4. When prompted, ensure “Add Git to PATH” is selected.

After installation, restart your computer.

✅ Step 3: Add Git to System PATH Manually

If git is still not recognized after installation, follow these steps:

  1. Open File Explorer and navigate to: C:\Program Files\Git\cmd
    • If Git is installed in a different location, find the correct path.
  2. Copy the Path (C:\Program Files\Git\cmd).
  3. Add Git to PATH:
    • Press Win + R, type sysdm.cpl, and press Enter.
    • Go to the Advanced tab and click Environment Variables.
    • Under System Variables, find Path, select it, and click Edit.
    • Click New, and paste the copied path (C:\Program Files\Git\cmd).
    • Click OK, then Apply, and restart your computer.

✅ Step 4: Verify Git is Working

After restarting, open PowerShell and run:

git --version

If it shows something like git version 2.x.x, Git is now installed and working! 🎉

✅ Step 5: Continue with Hugo Theme Installation

Now, you can retry adding the Hugo theme:

git init
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke

Final Summary

✅ Verified Git installation
✅ Installed Git manually (if needed)
✅ Added Git to the system PATH
✅ Restarted the system and confirmed Git is working
✅ Successfully continued with Hugo setup

Now, Git should work, and you can proceed with your Hugo website! 🚀😊

c. Here’s a dummy content format for MY HOSPITAL NOW (MHN) that you can use when creating a new post in Hugo.

1️⃣ Create a New Blog Post for MHN

Run this command in PowerShell inside your Hugo project directory:

hugo new posts/mhn-introduction.md

This will create a new Markdown file inside the content/posts/ folder.

2️⃣ Open and Edit the Post

Run:

notepad content/posts/mhn-introduction.md

Now, add the following dummy content for MHN:

---
title: "Welcome to My Hospital Now (MHN)"
date: 2025-02-14T10:00:00+05:30
draft: false
author: "MHN Team"
tags: ["Healthcare", "Medical Tourism", "Doctor Profiles"]
---

## 🏥 Welcome to **MY HOSPITAL NOW (MHN)**

### **🌍 Your Global Medical Tourism Partner**
MY HOSPITAL NOW (MHN) is your **trusted platform** for connecting patients with the right **doctors, hospitals, and medical services** worldwide.

### **💡 Why Choose MHN?**
✔ **Find Top-Rated Doctors** – View verified doctor profiles with credentials and specialties.  
✔ **Compare Hospitals** – Get insights into hospital facilities, patient reviews, and treatment options.  
✔ **Medical Tourism Assistance** – We help international patients get **hassle-free** medical treatment abroad.  

### **📌 Services We Offer**
🔹 **Doctor Profiles:** Browse verified doctors specializing in various treatments.  
🔹 **Hospital Listings:** Find hospitals with advanced medical facilities.  
🔹 **Surgery & Treatment Packages:** Get cost estimates and details on popular surgeries.  
🔹 **Consultation & Second Opinions:** Speak to a medical expert online before making a decision.  

### **🌟 Featured Doctors**
👨‍⚕️ **Dr. Pallavi Gupta** – Senior Homeopath with 10+ years of experience.  
👩‍⚕️ **Dr. Anil Sharma** – Leading Cardiologist in India with 15+ years of expertise.  

### **📞 Contact Us**
📍 **Location:** New Delhi, India  
📧 **Email:** contact@myhospitalnow.com  
🌐 **Website:** [www.myhospitalnow.com](http://www.myhospitalnow.com)  

---
🚀 *Helping Patients Find the Best Healthcare Worldwide!*  

3️⃣ Save and Preview the Post

  • Save the file (Ctrl + S) and Close Notepad.
  • Start the Hugo server to preview the post: hugo server -D
  • Open your browser and visit: http://localhost:1313
  • You should see the MHN post on your Hugo website! 🎉

Final Summary

✅ Created a dummy MHN post with hospital & doctor details
✅ Edited and formatted the content using Markdown
✅ Successfully previewed the post using Hugo

Let me know if you want to customize this further! 🚀😊

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x