Skip to content

Commit 2ec1bde

Browse files
author
Rubel Hossain
committed
chore: added AGENTS and hugo-template-guidance skill
1 parent 9ff2e6b commit 2ec1bde

15 files changed

Lines changed: 684 additions & 1 deletion
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: hugo-template-guidance
3+
description: Use whenever you need to understand how this theme works — adding pages, managing content, configuring the site, using partials/components/modules, project architecture, scripts, or styling/theming (Tailwind v4, Bootstrap 5, or a hybrid — verify which). Use for ANY question about the structure, usage, or customization of the template or theme.
4+
---
5+
6+
# Template Guidance
7+
8+
Handbook for this theme (Hugo Extended + Hugo Modules; styling is Tailwind v4, Bootstrap 5, or a hybrid — verify before assuming), assuming the standard **project-setup** layout (site at root, theme vendored in `themes/<theme>/` — the single folder under `themes/`; see `references/detect-mode.md` to find its name). Progressive disclosure: **read the matching `references/` file before acting.**
9+
10+
> If `exampleSite/hugo.toml` exists, the repo is still in theme-setup — run `<pm> project-setup` first (see `references/detect-mode.md`) before using anything below.
11+
>
12+
> **Package manager:** `<pm>` is a placeholder for this project's package manager. Detect it from a lock file (`pnpm-lock.yaml`, `package-lock.json`, `yarn.lock`, `bun.lock`/`bun.lockb`) or `package.json`'s `packageManager` field before running any command below — don't assume `pnpm`. Details: `references/script-usage.md`.
13+
14+
## Routing Guide
15+
16+
| Request | Read |
17+
| -------------------------------------------------------------- | ------------------------------------ |
18+
| Detect or convert setup mode (theme-setup vs project-setup) | `references/detect-mode.md` |
19+
| pre-flight checks (Node, Hugo version, package manager) | `references/preflight-checks.md` |
20+
| Architecture, folder layout, data flow | `references/project-architecture.md` |
21+
| Add a page, route, or homepage section | `references/adding-new-pages.md` |
22+
| Partials, components, shortcodes, Hugo Modules | `references/component-usage.md` |
23+
| Add, remove, or enable a Hugo Module (`module.toml`) | `references/hugo-modules.md` |
24+
| Markdown content, frontmatter, taxonomies | `references/content-management.md` |
25+
| Add/configure a new language, multilingual, i18n, translate | `references/i18n-guidance.md` |
26+
| Site config, menus, social, feature toggles, SEO | `references/page-configuration.md` |
27+
| Package manager detection, scripts, generators, module updates | `references/script-usage.md` |
28+
| Styling/theming (Tailwind v4, Bootstrap 5, or hybrid — verify first), dark mode, design tokens | `references/styling-and-theming.md` |
29+
30+
## Steps
31+
32+
1. Read the matching reference.
33+
2. Follow it.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Adding New Pages or New Sections
2+
3+
Hugo derives the URL from the content path under the language `contentDir`, and the template from section/kind/`layout`. Content goes under `content/english/` (root, project-setup).
4+
5+
There are three distinct things you'll be asked for — pick the matching recipe:
6+
7+
| Asking for... | It means... | Recipe |
8+
| --------------------------------------------------------------- | --------------------------------------------------------------------- | -------- |
9+
| "Add a page like About" (custom layout, image, hero, etc.) | Content + a **dedicated template** selected via `layout:` frontmatter | Recipe 1 |
10+
| "Add a page like Elements / Privacy Policy" (just text content) | Content only, rendered by the **existing generic template** | Recipe 2 |
11+
| "Add a section like Call to Action" (homepage block) | A **content block** + **partial** wired into `home.html` | Recipe 3 |
12+
13+
## Where new/overridden layouts go — root `layouts/`, never `themes/<theme>/layouts/`
14+
15+
Hugo's union filesystem makes root take precedence over the theme for the **same relative path**. This is the standard Hugo way to customize a theme without forking it, and it's how this theme stays upgradeable:
16+
17+
- **New templates, template overrides, new sections, new partials/components** → create them under root `layouts/` at the same relative path the theme would use (e.g. `layouts/about.html`, `layouts/_partials/components/my-card.html`).
18+
- **Never create or edit files directly under `themes/<theme>/layouts/`** — those are vendored and reset/overwritten on theme updates (`<pm> update-theme` etc.).
19+
- To override an existing theme template/partial, copy it from `themes/<theme>/layouts/...` to the identical path under root `layouts/...`, then edit the copy.
20+
- To add something brand new (a new partial, a new template, a new shortcode), just create it under root `layouts/...` directly — no theme copy needed.
21+
22+
## Recipe 1 — Custom-templated page with frontmatter (like `about`)
23+
24+
Use when the page needs its own layout (hero image, custom sections) beyond plain content — not just a title + body.
25+
26+
1. **Content**`content/english/<page-name>/_index.md`. Page info goes in the frontmatter. follow related pages as example
27+
28+
2. **Template**`layouts/<layout-name>.html` (root, mirroring the theme path — see above). Define `"main"` and read `.Title`, `.Params.*`, `.Content`.
29+
- The frontmatter `layout: "<name>"` must match the template filename (`layouts/<name>.html`).
30+
- **Analyze an existing template first** (`about.html`, `contact.html`) for the structure, partials used, and how it reads frontmatter — copy it if needed.
31+
32+
## Recipe 2 — Generic markdown page (like `elements`, `privacy-policy`)
33+
34+
Use when the page is just a title + long-form content — no custom layout needed.
35+
36+
1. **Content only**`content/english/pages/<page-name>.md`, frontmatter has **no `layout` field**:
37+
2. **No template needed** — falls through to the existing `single.html`.
38+
39+
## Recipe 3 — New section (like `call-to-action`)
40+
41+
Use when adding a new block to the homepage or any other page that's toggled on/off and editable via content frontmatter.
42+
43+
1. **Content block**`content/english/sections/<section-name>.md`. Must include `enable: true/false` and `build.render: "never"` (so it doesn't become a standalone page); add whatever params the partial needs:
44+
45+
```yaml
46+
---
47+
enable: true
48+
title: "Section title"
49+
image: "/images/my-section.png"
50+
description: "Section description"
51+
button:
52+
enable: true
53+
label: "Call to action"
54+
link: "https://example.com"
55+
build:
56+
render: "never"
57+
---
58+
```
59+
60+
2. **Partial**`layouts/_partials/my-section.html` (root, new file — no theme copy needed). Fetch the content via `site.GetPage`, gate on `.Params.enable`, render using `.Title` / `.Params.*`:
61+
62+
```go-html-template
63+
<!-- My Section -->
64+
{{ with site.GetPage "sections/my-section" }}
65+
{{ if .Params.enable }}
66+
<section class="section">
67+
<div class="container">
68+
<h2>{{ .Title | markdownify }}</h2>
69+
<p>{{ .Params.description | markdownify }}</p>
70+
{{ with .Params.button }}
71+
{{ if .enable }}
72+
<a class="btn btn-primary" href="{{ .link | absURL }}">{{ .label }}</a>
73+
{{ end }}
74+
{{ end }}
75+
</div>
76+
</section>
77+
{{ end }}
78+
{{ end }}
79+
<!-- /My Section -->
80+
```
81+
82+
3. **Wire into the page layout**`layouts/home.html` (root override; copy from `themes/<theme>/layouts/home.html` first if not already present), add:
83+
84+
```go-html-template
85+
{{ partial "my-section" . }}
86+
```
87+
88+
Place it in the right position relative to the other `{{ partial ... }}` / section blocks already in `home.html`.
89+
90+
## Navigation
91+
92+
Surface a page (Recipes 1 & 2) via `config/_default/menus.en.toml` (don't hardcode links), if not exists find it on other places.
93+
94+
```toml
95+
[[main]]
96+
name = "My New Page" url = "/my-new-page" weight = 5 # parent = "Pages" to nest
97+
```
98+
99+
## Linking other pages with relative URLs
100+
101+
`<a href="{{ .link | absURL }}">` — Hugo's `absURL` generates the correct URL based on the content path and `[permalinks]` config. Don't hardcode paths.
102+
103+
## DO NOT
104+
105+
- Use legacy paths — `_partials/`, `home.html`, top-level `baseof.html`.
106+
- Create or edit files directly under `themes/<theme>/layouts/` — add new templates/sections/components or override existing ones under root `layouts/` at the same relative path.
107+
- Add a `layout:` frontmatter field that doesn't match an existing/new `layouts/<name>.html` (Recipe 1) — Hugo silently falls back to the default template.
108+
- Omit `{{ define "main" }}` — page renders with no head/header/footer/SEO.
109+
- Invent frontmatter — copy a same-recipe page (e.g. copy `about` for Recipe 1, `privacy-policy` for Recipe 2, `call-to-action` for Recipe 3).
110+
- Create a section file (Recipe 3) without `build.render: "never"` (stray page).
111+
- Hardcode nav links; guess permalink behavior — check `[permalinks]` in `hugo.toml`.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Component Usage
2+
3+
Template/partial/module architecture. Theme templates live in `themes/<theme>/layouts/`; override by recreating the same path under **root** `layouts/` (Hugo unions root over theme).
4+
5+
## New template system (don't "fix" to legacy)
6+
7+
Hugo 0.146+: partials in **`layouts/_partials/`** (not `partials/`), homepage **`home.html`** (not `index.html`), base **`baseof.html`** top-level (not `_default/baseof.html`).
8+
9+
```text
10+
themes/<theme>/layouts/
11+
baseof.html # <html>/<head>/body, {{ block "main" . }}
12+
home.html single.html list.html taxonomy.html term.html about.html contact.html 404.en.html
13+
blog/ authors/ # section list.html + single.html
14+
_partials/ # reusable partials
15+
essentials/ # head, header, footer, script, style (used by baseof)
16+
components/ # author-card, blog-card, breadcrumb, pagination, theme-switcher, language-switcher, tw-size-indicator
17+
widgets/ # categories, tags, widget-wrapper
18+
page-header.html call-to-action.html
19+
```
20+
21+
**List `themes/<theme>/layouts/` + `_partials/` (and any root `layouts/` overrides) before assuming a template exists.** Many partials (`image`, `basic-seo`, `search-modal`, `favicon`, `manifest`, `announcement`…) come from **Hugo Modules**, not this repo.
22+
23+
## Partials & Modules
24+
25+
- `{{ partial "name.html" . }}`; `{{ partialCached ... }}` for page-invariant output (styles, scripts, announcement) — `baseof.html` does this deliberately; match it.
26+
- Override a **module** partial by creating the same path in root `layouts/_partials/` (union FS wins).
27+
- `config/_default/module.toml` lists available `gethugothemes/hugo-modules` modules, check `https://github.com/gethugothemes/hugo-modules` for more.
28+
- **Active:** `llms-txt`, `search`, `pwa`, `images`, `videos`, `icons/font-awesome`, `gzip-caching`, `adsense`, `accordion`, `table-of-contents``tab`, `modal`, `gallery-slider`, `components/{preloader,announcement,cookie-consent,social-share,custom-script,open-remark,render-link}`, `shortcode{button,notice,mermaid}`, `seo-tools/{basic-seo,site-verifications,google-tag-manager}`.
29+
- **Disabled but available** (commented out): `icons/themify-icons`, `components/{valine-comment,crisp-chat}`, `seo-tools/{baidu-analyticmatomo-analytics,plausible-analytics,counter-analytics}`.
30+
- You can create custom partial components into `layouts/_partials/` and use them in templates, but for anything non-trivial, check if a module already provides it first.
31+
- You can create custom shortcodes in `layouts/shortcodes/` and use them in content, but check if a module already provides it first (e.g. `button`, `notice`, `mermaid`, accordion/tab/modal/gallery shortcodes come from modules).
32+
33+
# Most used Shortcodes or Partials
34+
35+
- **Image Module**: responsive images with Tailwind classes, lazy loading, optional XL display; accepts `Src`, `Alt`, `Class`, `Loading`, and `DisplayXL` etc keys in a dict. check `https://github.com/gethugothemes/hugo-modules/tree/master/images` for more (e.g. `DisplayXL` makes it full-width on XL screens and above, but normal on smaller screens and can use background-image can also use at shortcode). Also very important the images are stored in `/assets/images/` (not `static/`) so they get processed by Hugo's image pipeline and can be used with the `image` partial/shortcode.
36+
partial example: `{{ partial "image" (dict "Src" .Params.featured_image "Alt" .Title "Class" "my-4 rounded-lg") }}`
37+
shortcode example: `{{< image src="/path/to/image.jpg" alt="Alt text" class="my-4 rounded-lg" display_xl=true >}}`
38+
- **Page Header**: used on almost all single, list or custom templates; accepts `Title`, `Subtitle`, and `Background` keys in a dict; check `layouts/_partials/page-header.html` for usage.
39+
example: `{{ partial "page-header" . }}` or `{{ partial "page-header" (dict "Title" .Title "Subtitle" .Params.subtitle "Background" .Params.featured_image) }}`
40+
41+
# Reusable components
42+
43+
Reusable components should be added as partials under `layouts/_partials/components/` and used via `{{ partial "components/name.html" . }}`. Check the existing components for examples of how to write them, and check if a Hugo Module already provides the component before creating a new one.
44+
45+
## Styling
46+
47+
Tailwind utilities + tokens (`text-primary`, `bg-body`, `dark:bg-darkmode-body`); reusable CSS classes in `assets/css/components.css` or `custom.css`. See `references/styling-and-theming.md`.
48+
49+
## DO NOT
50+
51+
- Rename `_partials/``partials/`, `home.html``index.html`, or move `baseof.html` into `_default/`.
52+
- Assume a partial is missing because it's not in `themes/<theme>/layouts/` — check `module.toml` first.
53+
- Edit a vendored module in the Go cache, or files under `themes/<theme>/` directly — override via root `layouts/`.
54+
- Hand-roll `<img>` for content images — use `partial "image"`. Hardcode hex — use tokens.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Content Management
2+
3+
Markdown under the language content dir, rendered via Hugo's content/layout pairing. Content lives at root: `content/english/`.
4+
5+
## Architecture
6+
7+
Multilingual — each language sets `contentDir` in `config/_default/languages.toml` (English → `content/english/`). **List the dir before assuming the language** (e.g. `content/english/blog/post.md` → English, not `content/blog/post.md`).
8+
Common examples often found here include:
9+
10+
- **Blog Posts**: `blog/` (posts + `_index.md`).
11+
- **Authors**: `authors/` (one file each + `_index.md`).
12+
- **Pages**: `about/_index.md`, `contact/_index.md`, `pages/*.md`.
13+
- **Reuseable Sections**: `sections/*.md`.
14+
15+
## Frontmatter (common fields)
16+
17+
Hugo reads what templates expect, so **mirror an existing file in the same section** rather than guessing.
18+
19+
- `title`: String. The main title of the post.
20+
- `date`: ISO Date string (e.g., `2022-04-04T05:00:00Z`), use exact current time for `date` otherwise Hugo won't render it.
21+
- `description`: String. Short summary used for lists and SEO.
22+
- `image`: String. Path to the cover image (starts with `/images/`).
23+
- `draft`: Boolean (`true`/`false`).
24+
25+
## Section-specific common frontmatter:
26+
27+
- **Blog post**: `title`, `meta_title`, `description`, `date`, `image`, `categories[]`, `tags[]`, `author`, `draft`. `author` must match an author `title` in `authors/`; `categories`/`tags` are taxonomies (links auto); `draft: true` hides in prod.
28+
- **Author**: `title`, `email`, `image`, `description`, `social[]`.
29+
- **any reuseable section** (`sections/*.md`): `enable`, `title`, `image`, `description`, `button` (`enable`/`label`/`link`), and `build.render: "never"`
30+
31+
## Naming, Images, i18n
32+
33+
- Kebab-case filenames → URL slug (`my-post.md``/blog/my-post/`). Section landing = `_index.md` (branch bundle); co-located resources = `page/index.md` (leaf bundle).
34+
- Images go under `assets/images/` and use image module `{{ partial "image" (dict "Src" .image "Alt" "..." "Loading" "eager" "Class" "..." "DisplayXL" "800x") }}` — don't hand-write `<img>`.
35+
36+
## Common Mistakes / What NOT to do
37+
38+
- **DO NOT** Reference an `author` with no file in `authors/`.
39+
- **DO NOT** Drop `build.render: "never"` from section files (creates stray pages).
40+
- **DO NOT** Use relative image paths — use `/images/...` under `assets/images/`.
41+
- **DO NOT** Put content outside the language `contentDir`.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Detect Setup Mode
2+
3+
This theme ships in two structures; the same logical file lives at a different path in each. **Always detect the current mode first** — before reading or editing any content, config, layout, style, or script file.
4+
5+
## Detection
6+
7+
- **`exampleSite/hugo.toml` exists → theme-setup** — theme at root (`layouts/`, `assets/`, `theme.toml`), demo site in `exampleSite/`.
8+
- **Root `hugo.toml` + `themes/` → project-setup** — site at root (`content/`, `config/`, `data/`, `hugo.toml`), theme vendored in `themes/<theme>/` (the single folder under `themes/` — run `ls themes/` to confirm its name; in this repo it's `hugoplate`).
9+
10+
### Edge case
11+
12+
If all of the following are true:
13+
14+
- `exampleSite/` exists
15+
- `themes/<theme>/` exists
16+
- `exampleSite/hugo.toml` is the active Hugo config
17+
- `themes/<theme>/layouts/home.html` does **not** exist
18+
19+
then treat the repository as **theme-setup**, not **project-setup**. So Before running `<pm> project-setup` or `<pm> dev` ask user if they want to delete the `themes/` directory and run `<pm> project-setup` to convert to project-setup, deleting `themes/` is required otherwise when running `<pm> project-setup`, it will detect current mode as `project-setup` which is false.
20+
21+
## Always work in `project-setup` mode
22+
23+
If the repo or project is currently in theme-setup, run `<pm> project-setup` **before** editing or reading any content, config, layout, or style file — this is non-negotiable.
24+
25+
- **Idempotent** — logs "Project already setup" and no-ops if already converted, so it's always safe to run.
26+
- **Never move files between modes by hand** — only `<pm> project-setup` / `<pm> theme-setup` (reverse) do this correctly.
27+
- `dev:example` / `build:example` / `preview:example` scripts exist only for theme-setup (run against `exampleSite/`). Once converted via `<pm> project-setup`, they no longer apply — don't reach for them as a shortcut to avoid converting.
28+
29+
## After conversion
30+
31+
For the full project-setup folder layout and path-resolution table, see `references/project-architecture.md`.
32+
33+
## Canonical source
34+
35+
This file is the canonical source for setup-mode detection and conversion. `AGENTS.md` and the other references in this skill link here instead of repeating the rule.

0 commit comments

Comments
 (0)