gohugoio/hugo · error

resource %T does not support resource.Source

Error message

resource %T does not support resource.Source

What it means

Emitted from pageState.renderResources (page.go:739). When publishing a page's non-Page resources, Hugo type-asserts each resource to resource.Source (the interface providing Publish()). If a resource does not satisfy that interface, the build aborts — a resource was attached to a page that has no notion of being published to the output filesystem.

Source

Thrown at hugolib/page.go:739

}

func (ps *pageState) renderResources() error {
	for _, r := range ps.Resources() {
		if _, ok := r.(page.Page); ok {
			if !ps.s.h.BuildState.IsRebuild() {
				// Pages gets rendered with the owning page but we count them here.
				ps.s.PathSpec.ProcessingStats.Incr(&ps.s.PathSpec.ProcessingStats.Pages)
			}
			continue
		}

		if resources.IsPublished(r) {
			continue
		}

		src, ok := r.(resource.Source)
		if !ok {
			return fmt.Errorf("resource %T does not support resource.Source", r)
		}

		if err := src.Publish(); err != nil {
			if !herrors.IsNotExist(err) {
				ps.s.Log.Errorf("Failed to publish Resource for page %q: %s", ps.pathOrTitle(), err)
			}
		} else {
			ps.s.PathSpec.ProcessingStats.Incr(&ps.s.PathSpec.ProcessingStats.Files)
		}
	}

	return nil
}

func (ps *pageState) AlternativeOutputFormats() page.OutputFormats {
	f := ps.outputFormat()
	var o page.OutputFormats
	for _, of := range ps.OutputFormats() {

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Inspect the %T in the message to learn which concrete resource type is missing Publish().
  2. Ensure any custom resource type implements resource.Source (Publish() error) in addition to resource.Resource.
  3. Update the Hugo module/wrapper that produced the resource to a compatible version.
Defensive patterns

Strategy: type-guard

Type guard

// for Go integrations injecting resources: ensure they satisfy resource.Source
func isPublishable(r resource.Resource) bool {
    _, ok := r.(resource.Source) // requires Publish() error
    return ok
}

Prevention

When it happens

Trigger: A custom resource type, or a constructed resource object that implements resource.Resource but not resource.Source, is present in a page's Resources() collection at publish time. Typically a programming/integration bug rather than an authoring mistake.

Common situations: Embedding Hugo as a library and injecting a custom resource; a resource adapter returning an incomplete type; a stale/incompatible Hugo module that wraps resources incorrectly.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/70d2ee880a2b2ceb. Report an issue: GitHub.