gthmchttr

📟 Publishing a blog using Hugo

A no-nonsense opinionated guide to get your blog published using hugo, github, cloudflare pages and godaddy.

This publishing workflow is not meant for total beginners, but should be more of a hand-holding guide for someone:

If you would rather prefer a more straightforward & less involved way to blog, consider bear blog instead.

Index :

Step 1 : Setting up Hugo

  1. Install Hugo : Mac | Windows | Linux
  2. Install Git : Mac | Windows | Linux
  3. Check if hugo is installed properly by running : hugo version
  4. Choose a project folder, usually documents folder works :
        # Mac / Linux 
        mkdir ~/Documents/Projects/; cd ~/Documents/Projects/
        # Windows 
        mkdir %USERPROFILE%\Documents\Projects & cd %USERPROFILE%\Documents\Projects
    
  5. Choose a project name (for a personal blog something like <your-name>-blog just works) and run - hugo new site <your-name>-blog.
  6. A new directory would be created, step into that :
        # Mac / Linux 
        cd ~/Documents/Projects/<your-name>-blog
        # Windows 
        cd %USERPROFILE%\Documents\Projects<your-name>-blog
    
  7. Initialize git repository : git init

Theming

  1. Choose a theme from - themes.gohugo.io (e.g: this blog uses hugo-bearblog)
  2. Go to git repository of that theme using download button - hugo download button
  3. Now there are 2 ways to use this in your blog [?] -
    1. Simple but sometimes restrictive - directly add above git project as a submodule :
      git submodule add https://github.com/janraasch/hugo-bearblog.git.
    2. (recommended) Slight maintainance overhead but highly customizable -
      • Fork the project :
        git fork button
      • Add forked project as a submodule :
        git submodule add https://github.com/gauthamchettiar/hugo-bearblog.git
  4. Add above theme to hugo.toml -
    echo "theme = 'hugo-bearblog'" >> hugo.toml

Step 2 : Writing your first post

  1. Run below command to create a new post (⚠️ this is dependent on theme implementation, check theme specific README first) -
    hugo new blog/<post-subject>.md
  2. A new markdown file would be created at - content/blog/<post-subject>.md hugo md file Again, your file might look slightly different based on theme you choose.
  3. Edit this markdown file to include your post content.
  4. Preview your blog locally :
    hugo server -D
  5. Go to web server link provided in output, usually http://localhost:1313/ :
        ...
        Built in 72 ms
        Environment: "development"
        Serving pages from disk
        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
    
  6. You should be able to preview your web page here. Also, this would be auto-updated every time you make changes to your markdown file and save it :
        ...
        Change detected, rebuilding site (#36).
        2025-10-06 13:43:53.971 +0100
        Source changed /blog/20251106_publishing_using_hugo.md
        Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
        Total in 4 ms
    

Step 3 : Pushing to Github

  1. Create a new repository on github.
  2. Copy <github-project-url> from above created project : e.g https://github.com/gauthamchettiar/gauthamchettiar.github.io
  3. Run below set of commands from your hugo blog directory :
    1git add .
    2git commit -m "Initial commit"
    3git branch -M main
    4git remote add origin <github-project-url> # replace with copied URL
    5git push -u origin main
    

Step 4 : Publishing using Cloudflare Pages

  1. Signup for Cloudflare Pages account, if you have not done it yet.
  2. Search for “Workers & Pages”, and go to that page : Cloudflare - Workers & Pages Seach As of writing this post, this is at Compute (Workers) > Workers & Pages
  3. Click on “Create Application” : Cloudflare - Create Application
  4. Select repository : Cloudflare - Deploy 1
    • Link your github account to cloudflare pages using “Add Account”, then
    • Choose the repository where hugo blog is pushed to, and
    • Click on “Begin Setup”.
  5. Setup builds and deployments: Cloudflare - Deploy 2
    • Choose a name for your project, this will be deployed as:
      https://<project-name>.pages.dev
    • Choose “Production branch” as “master”, then
    • Choose “Framework Preset” as “Hugo”, and
    • Click on “Save and Deploy”
  6. Your deployment would finish and you would be given a link where your app is deployed : Cloudflare - Deploy 3
  7. This is a WWW link that you can immediately start sharing with everyone.

Step 5 (Optional) : Setting up custom domain

While this is not required, it’s nice to have a permanent address on internet.

  1. HARDEST PART come up with a good domain name for your blog, I choose to keep my actual name as domain.
  2. Buy a domain on GoDaddy, or any website where you find registration and renewal options to be cheapest.
  3. Go back to cloudflare “Workers & Pages” > “Custom Domain” > “Set up a custom domain” : Cloudflare - Custom Domain 1
  4. Add a domain, it could include a subdomain (blog.yourdomain.com) if you wish: Cloudflare - Custom Domain 2
  5. Once you click on “Activate domain” it would add your record to it’s DNS.
  6. In order for cloudflare to manage DNS records, you need to add nameservers displayed in cloudflare to GoDaddy : GoDaddy Nameserver Setup
  7. It could take upto 24 hours for entire thing to be up and running!

Aaaaand, That’s it!

#Blogging