diff --git a/hugolib/site_output_test.go b/hugolib/site_output_test.go
index f3455f3692c..815625ff10d 100644
--- a/hugolib/site_output_test.go
+++ b/hugolib/site_output_test.go
@@ -324,6 +324,36 @@ baseName = "customdelimbase"
c.Assert(outputs.Get("CUS").RelPermalink(), qt.Equals, "/blog/customdelimbase_del")
}
+// Issue 8030
+func TestGetOutputFormatRel(t *testing.T) {
+ b := newTestSitesBuilder(t).
+ WithSimpleConfigFileAndSettings(map[string]interface{}{
+ "outputFormats": map[string]interface{}{
+ "humansTXT": map[string]interface{}{
+ "name": "HUMANS",
+ "mediaType": "text/plain",
+ "baseName": "humans",
+ "isPlainText": true,
+ "rel": "author",
+ },
+ },
+ }).WithTemplates("index.html", `
+{{- with ($.Site.GetPage "humans").OutputFormats.Get "humans" -}}
+
+{{- end -}}
+`).WithContent("humans.md", `---
+outputs:
+- HUMANS
+---
+This is my content.
+`)
+
+ b.Build(BuildCfg{})
+ b.AssertFileContent("public/index.html", `
+
+`)
+}
+
func TestCreateSiteOutputFormats(t *testing.T) {
t.Run("Basic", func(t *testing.T) {
c := qt.New(t)
diff --git a/resources/page/page_outputformat.go b/resources/page/page_outputformat.go
index 9eed8241e6d..44f29002517 100644
--- a/resources/page/page_outputformat.go
+++ b/resources/page/page_outputformat.go
@@ -66,8 +66,18 @@ func (o OutputFormat) RelPermalink() string {
}
func NewOutputFormat(relPermalink, permalink string, isCanonical bool, f output.Format) OutputFormat {
+ isUserConfigured := true
+ for _, d := range output.DefaultFormats {
+ if strings.EqualFold(d.Name, f.Name) {
+ isUserConfigured = false
+ }
+ }
rel := f.Rel
- if isCanonical {
+ // If the output format is the canonical format for the content, we want
+ // to specify this in the "rel" attribute of an HTML "link" element.
+ // However, for custom output formats, we don't want to surprise users by
+ // overwriting "rel"
+ if isCanonical && !isUserConfigured {
rel = "canonical"
}
return OutputFormat{Rel: rel, Format: f, relPermalink: relPermalink, permalink: permalink}