ResourceType
Returns the main type of the given resource’s media type.
- Syntax
- RESOURCE.ResourceType
- Returns
- string
Use this method with global resources, page resources, or remote resources.
Common resource types include audio, image, text, and video.
{{ with resources.Get "image/a.jpg" }}
{{ .ResourceType }} → image
{{ .MediaType.MainType }} → image
{{ end }}When working with content files, the resource type is page.
content/
├── lessons/
│ ├── lesson-1/
│ │ ├── _objectives.md <-- resource type = page
│ │ ├── _topics.md <-- resource type = page
│ │ ├── _example.jpg <-- resource type = image
│ │ └── index.md
│ └── _index.md
└── _index.mdWith the structure above, we can range through page resources of type page to build content:
layouts/lessons/page.html
{{ range .Resources.ByType "page" }}
{{ .Content }}
{{ end }}Last updated:
June 18, 2026
:
Merge commit 'c86d9f4aa8a58931f52df6516f10b67c807505fb' (be780afa7)
Improve this page