搜索

PythonReactSEOPDF
GitHub Skill

hugo

Build, configure, and develop Hugo static sites and themes. Use when the user wants to create a new Hugo site, develop or customize a Hugo theme, write Hugo templates (layouts, partials, shortcodes), configure hugo.toml/yaml/json, work with Hugo's asset pipeline (images, CSS/Sass, JS bundling), manage content (pages, sections, taxonomies, menus), or deploy a Hugo site. Triggers on mentions of "Hugo", "hugo.toml", "static site generator", Hugo-related template syntax (Go templates, baseof, partials), or Hugo content workflows.

NeverSight☆ 66 仓库 Stars19 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Hugo Static Site Generator

Quick Reference

Core Commands

hugo new site my-site        # Create new site
hugo new theme my-theme      # Create theme skeleton
hugo new content posts/my-post.md  # Create content
hugo server -D               # Dev server (include drafts)
hugo server --navigateToChanged    # Auto-navigate to changed content
hugo                         # Build site to public/
hugo --minify                # Build with minified output
hugo --gc                    # Build and clean unused cache
hugo mod init github.com/user/repo  # Initialize Hugo modules

Project Structure

my-site/
├── hugo.toml              # Site configuration
├── archetypes/            # Content templates for `hugo new`
│   └── default.md
├── assets/                # Files processed by Hugo Pipes (Sass, JS, images)
├── content/               # Site content (Markdown)
├── data/                  # Data files (JSON, TOML, YAML)
├── i18n/                  # Translation strings
├── layouts/               # Templates (override theme)
├── static/                # Static files copied as-is
├── themes/                # Installed themes
└── public/                # Generated site (build output)

Workflow

Creating a New Site
  1. Run hugo new site <name> to scaffold
  2. Configure hugo.toml — see references/configuration.md
  3. Add a theme (install or create custom) — see references/theme-development.md
  4. Create content with hugo new content <section>/<name>.md
  5. Run hugo server -D for live development
  6. Build with hugo --minify for production
Theme Development

Create custom themes or modify existing ones. See references/theme-development.md for:

  • Theme directory structure and skeleton
  • Template lookup order
  • Base templates (baseof.html) and blocks
  • Partials and partial caching
  • List and single templates
  • Taxonomy and term templates
Templating

Write Go templates for layouts, partials, and shortcodes. See references/templating.md for:

  • Go template syntax and functions
  • Context (the dot .) and variable scoping
  • Range, with, if/else patterns
  • Custom shortcodes
  • Template debugging
Content Management

Organize and manage site content. See references/content-management.md for:

  • Page bundles (leaf vs branch)
  • Front matter fields
  • Sections and taxonomies
  • Menus
  • Multilingual / i18n
  • Content archetypes
Asset Pipeline

Process images, CSS/Sass, JavaScript, and more. See references/asset-pipeline.md for:

  • Image processing (resize, crop, filters, WebP)
  • Sass/SCSS compilation
  • JavaScript bundling with esbuild
  • Fingerprinting and SRI
  • PostCSS / Tailwind CSS integration
Deployment

Deploy to hosting platforms. See references/deployment.md for:

  • Netlify configuration
  • Vercel setup
  • Cloudflare Pages
  • GitHub Pages with Actions
  • General CI/CD patterns

Best Practices

  • Keep images with content: Use page bundles (index.md + images in same directory) so Hugo can process them
  • Use hugo.toml config directory for complex sites: split into config/_default/hugo.toml, menus.toml, params.toml
  • Asset pipeline minimum: Always minify, fingerprint, and use slice for CSS/JS bundles
  • Override, don't fork themes: Place overriding templates in project layouts/ — Hugo's union file system gives project files precedence over theme files
  • Use partials for DRY templates: Break complex templates into focused partials; use partialCached for expensive operations
  • Content organization mirrors URL structure: Top-level directories under content/ become sections
  • Draft workflow: Use draft: true in front matter; hugo server -D shows drafts, production build excludes them
  • Use archetypes: Define content templates in archetypes/ for consistent front matter across content types

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-03-11
索引更新时间
2026-03-11
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!