๐Ÿž Breadcrumb Demo

Last updated๏ผš2026-11-25

Category pages automatically carry two layers of data โ€” “parent + current category” โ€” for you to assemble yourself. This page explains the usage with three real scenarios, a variable table, and template code, and provides a live assembly calculator. If the “Breadcrumb” row in Common Tags was unclear to you, this is the dedicated deep-dive.

1. What It Is

A breadcrumb is the navigation path at the top of a page โ€” “Home โ€บ News โ€บ Company Updates” โ€” telling visitors “which level of the site you are on”.

In templates, category pages (category list pages) automatically inject two kinds of data: the current category’s name, and its parent category (none if it is a top-level category). You only need to check for a parent, then assemble it.

2. Three Real Rendering Results

Scenario A ยท Child Category (has a parent)

Site structure: News (parent) โ†’ Company Updates (current) News/Company Updates

.ParentCategory exists โ†’ output “parent link / ” + current name

Scenario B ยท Top-level Category (no parent)

News (itself top-level, no parent) News

.ParentCategory is nil โ†’ output only the current name

Scenario C ยท Multi-level Nesting (grandparent / parent / current)

Product Center (grandparent) โ†’ Smart Hardware (parent) โ†’ Router (current) Product Center/Smart Hardware/Router

Each extra level adds one more {{if .ParentCategory...}} wrapper; see Section 4 for details

3. Available Variables

Variable Type / Meaning
{{.CategoryName}} Current category name (plain text), e.g. Company Updates. Present on any category page.
{{.ParentCategory}} Parent category object. nil (empty) for top-level categories; must check before use.
{{.ParentCategory.Name}} Parent name, e.g. News.
{{.ParentCategory.Link}} Parent link, e.g. /news.
{{.ParentCategory.ParentCategory}} Grandparent object (one more nesting level). Only for multi-level categories; also needs a check.

4. Template Code (Copy and Use)

โ‘  One level (parent + current) โ€” most category pages
{{if .ParentCategory}}<a href="{{.ParentCategory.Link}}">{{.ParentCategory.Name}}</a> / {{end}}{{.CategoryName}}

{{if .ParentCategory}} โ€ฆ {{end}} checks for a parent first: output “parent link / ” only if present, otherwise skip; {{.CategoryName}} always outputs the current category name.

โ‘ก Two levels (grandparent + parent + current) โ€” multi-level nested categories
{{if .ParentCategory}}{{if .ParentCategory.ParentCategory}}<a href="{{.ParentCategory.ParentCategory.Link}}">{{.ParentCategory.ParentCategory.Name}}</a> / {{end}}<a href="{{.ParentCategory.Link}}">{{.ParentCategory.Name}}</a> / {{end}}{{.CategoryName}}

Check level by level from the outside in: first the grandparent (optional), then the parent (optional), and finally always output the current name. For deeper levels, keep nesting inward the same way.

5. Live Assembly Calculator

Fill in the fields below and the rendered breadcrumb will appear live below (empty levels are skipped automatically).

Grandparent name (optional, e.g. Product Center) Parent name (optional, e.g. Smart Hardware) Current category name (required, e.g. Router)

6. Two Easy Pitfalls

  • Always write the {{if .ParentCategory}} check: if you write {{.ParentCategory.Link}} directly while the page is a top-level category (nil), the template errors out immediately.
  • Don’t confuse it with {{.BreadcrumbJSONLD}}: that one is breadcrumb structured data for search engines (BreadcrumbList, for SEO), separate from the human-visible HTML breadcrumb here; the two can coexist without conflict.

โ† Multi-select Iteration Friend Links โ†’

This site uses cookies for essential functionality and to improve your experience. See our Privacy Policy.