Quick Reference - Hugo Site Development

1. Local Development

1.1. Start

# Download dependencies (first time only)
hugo mod get -u

# Start development server
hugo server -D

# Open browser
# http://localhost:1313/my-documents/

1.2. Auto-reload

  • Edit markdown files
  • Browser auto-refreshes
  • Press Ctrl+C to stop

2. Adding Content

2.1. New Page in Existing Section

hugo new docs/bash-scripts/my-page.md

Edit the file with frontmatter:

---
title: My New Page
description: Brief description for SEO
weight: 10
categories: [Bash]
tags: [bash, example]
---

Your content here...

2.2. New Section

Create directory in content/en/docs/ and _index.md:

mkdir -p content/en/docs/new-section
touch content/en/docs/new-section/_index.md

2.3. Frontmatter Fields

---
title: Page Title              # Required, shown as H1
description: SEO description   # Required, used in meta tags
weight: 10                      # Optional, controls ordering (lower = earlier)
categories: [category-name]    # Optional, for content organization
tags: [tag1, tag2]             # Optional, for tagging
---

3. Content Organization

content/en/docs/
├── bash-scripts/          # Weight: 10 (first)
├── howtos/               # Weight: 20
│   └── howto-write-jenkinsfile/  # Subsection
├── lists/                # Weight: 30
└── other-projects/       # Weight: 40 (last)

Navigation: Automatic based on directory structure + weight frontmatter

4. Images and Assets

Place in static/ directory:

static/
├── howto-write-dockerfile/    # For Dockerfile guide images
├── howto-write-jenkinsfile/   # For Jenkins guide images
└── your-section/              # Create as needed

Reference in markdown:

![Alt text](/howto-write-dockerfile/image-name.png)

5. Common Docsy Shortcodes

5.1. Info Box


<div class="pageinfo pageinfo-primary">

This is an informational box.

</div>

5.2. Alert

<div class="alert alert-warning" role="alert"><div class="h4 alert-heading" role="heading">Warning</div>


This is a warning message.
</div>

5.3. Tabbed Content




<ul class="nav nav-tabs" id="tabs-2" role="tablist">
  <li class="nav-item">
      <button class="nav-link active"
          id="tabs-02-00-tab" data-bs-toggle="tab" data-bs-target="#tabs-02-00" role="tab"
          aria-controls="tabs-02-00" aria-selected="true">
        Tab 1
      </button>
    </li><li class="nav-item">
      <button class="nav-link"
          id="tabs-02-01-tab" data-bs-toggle="tab" data-bs-target="#tabs-02-01" role="tab"
          aria-controls="tabs-02-01" aria-selected="false">
        Tab 2
      </button>
    </li>
</ul>

<div class="tab-content" id="tabs-2-content">
    <div class="tab-pane fade show active"
        id="tabs-02-00" role="tabpanel" aria-labelled-by="tabs-02-00-tab" tabindex="2">
        <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;p&gt;Content for tab 1&lt;/p&gt;</span></span></code></pre></div>
    </div>
    <div class="tab-pane fade"
        id="tabs-02-01" role="tabpanel" aria-labelled-by="tabs-02-01-tab" tabindex="2">
        <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;p&gt;Content for tab 2&lt;/p&gt;</span></span></code></pre></div>
    </div>
</div>

See full list: https://www.docsy.dev/docs/reference/shortcodes/

6. Code Blocks

Specify language for syntax highlighting:

```bash
#!/bin/bash
echo "Hello World"
```

```yaml
key: value
nested:
  item: value
```

```python
def hello():
    print("Hello World")
```

Use relative paths:

[Link text](/docs/bash-scripts/page-name/)
[Link text](/docs/section/_index/)

Hugo resolves these automatically.

8. Building for Production

# Build minified site
hugo --minify

# Output goes to public/ directory
# GitHub Actions handles deployment automatically

9. Content Guidelines

  • Line length: 120 characters max (enforced by mdformat)
  • Headers: Use ATX style (#, ##, ###)
  • Lists: 2-space indentation
  • Code blocks: Always specify language
  • Images: Include alt text
  • Links: Use relative paths for internal, full URLs for external

10. Spell Checking

Add technical terms to .cspell/bash.txt:

echo "newWord" >>.cspell/bash.txt
pre-commit run file-contents-sorter # auto-sorts

11. Git Workflow

  1. Branch: Always use master
  2. Commit: Detailed message with changes
  3. Push: Triggers linting and Hugo build
  4. CI/CD: GitHub Actions handles rest
git add .
git commit -m "Add new documentation on topic"
git push origin master

12. Troubleshooting

12.1. Hugo server won’t start

rm go.sum
hugo mod clean
hugo mod get -u
hugo server -D

12.2. Module not found errors

hugo version # Check it says "extended"
hugo mod get -u

12.3. Build artifacts in way

rm -rf resources/ public/
hugo --minify
  • Check relative path is correct
  • Verify file exists in expected location
  • Internal links should start with /docs/

13. File Locations

ItemPath
Site confighugo.yaml
Home pagecontent/en/_index.html
Docs homecontent/en/docs/_index.md
Bash guidescontent/en/docs/bash-scripts/
How-TO guidescontent/en/docs/howtos/
Listscontent/en/docs/lists/
Imagesstatic/section-name/
Archetypesarchetypes/*.md
Theme confighugo.yaml params section

14. SEO Best Practices

  • ✅ Use descriptive titles and descriptions
  • ✅ Add weight to control ordering
  • ✅ Use categories and tags
  • ✅ Include proper alt text on images
  • ✅ Link to related content
  • ✅ Use clear heading hierarchy
  • ✅ Keep page descriptions under 160 chars

15. Submitting to Search Engines

  1. Build site: hugo --minify (GitHub Actions does this)
  2. GitHub Actions deploys to GitHub Pages
  3. Submit sitemap to search console:

16. Useful Commands

hugo server -D              # Run dev server
hugo --minify               # Build for production
hugo --printI18nWarnings    # Check for i18n issues
hugo --printPathWarnings    # Check path warnings
hugo --printUnusedTemplates # Check unused templates
pre-commit run -a           # Run all linters

17. Theme Customization

To override Docsy styles:

  1. Create /assets/scss/_custom.scss
  2. Add custom CSS
  3. Rebuild with hugo server

For more details: https://www.docsy.dev/docs/


Quick Links: