Skip to content

new template system: Shortcode template not found #13605

@jmooring

Description

@jmooring

This is not a backwards compatibility issue, but instead something unexpected.

content/
└── s1/
    └── p1.md  <-- calls {{< sc >}}
layouts/
├── s1/
│   └── _shortcodes/
│       └── sc.html
└── all.html

Result: failed to extract shortcode: template for shortcode "sc" not found

You can make it work by placing a dummy sc.html in layouts/_shortcodes, but it doesn't seem like that should be necessary.

Related: https://discourse.gohugo.io/t/54334

func TestIssue13605(t *testing.T) {
	t.Parallel()

	files := `
-- hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
-- content/s1/p1.md --
---
title: p1
---
{{< sc >}}
-- layouts/s1/_shortcodes/sc.html --
layouts/s1/_shortcodes/sc.html
-- layouts/single.html --
{{ .Content }}
`

	b := hugolib.Test(t, files)

	b.AssertFileContent("public/s1/p1/index.html", "layouts/s1/_shortcodes/sc.html")
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions