Repository: gohugoio/hugo (language: go)

Issue:
collections.EchoParam does not return boolean values
```text
[params.footer]
string = 'foo'
int = 42
float = 3.1415
bool = true
```

```
{{ echoParam .Site.Params.footer "string" }} --> foo (string)
{{ echoParam .Site.Params.footer "int" }}    --> 42 (int64)
{{ echoParam .Site.Params.footer "float" }}  --> 3.1415 (float64)
{{ echoParam .Site.Params.footer "bool" }}   --> "" (string)
```

...or deprecate the function. I'm not sure why we need three ways to do the same thing:

```text
{{ site.Params.footer.key }}
{{ index site.Params.footer "key" }}
{{ echoParam .Site.Params.footer "key" }}  <-- and with this one you need to lowercase the key, just like isset
```




Discussion / hints:

Fix patch:
diff --git a/tpl/collections/collections.go b/tpl/collections/collections.go
index 92aa2b9e6bb..2f7eb745bba 100644
--- a/tpl/collections/collections.go
+++ b/tpl/collections/collections.go
@@ -31,6 +31,7 @@ import (
 	"github.com/gohugoio/hugo/common/maps"
 	"github.com/gohugoio/hugo/common/types"
 	"github.com/gohugoio/hugo/deps"
+	"github.com/gohugoio/hugo/helpers"
 	"github.com/gohugoio/hugo/langs"
 	"github.com/gohugoio/hugo/tpl/compare"
 	"github.com/spf13/cast"
@@ -195,9 +196,11 @@ func (ns *Namespace) Dictionary(values ...any) (map[string]any, error) {
 	return root, nil
 }
 
-// EchoParam returns a the value in the collection c with key k if is set; otherwise, it returns an
+// EchoParam returns the value in the collection c with key k if is set; otherwise, it returns an
 // empty string.
+// Deprecated: Use the index function instead.
 func (ns *Namespace) EchoParam(c, k any) any {
+	helpers.Deprecated("collections.EchoParam", "Use the index function instead.", false)
 	av, isNil := indirect(reflect.ValueOf(c))
 	if isNil {
 		return ""
@@ -233,6 +236,8 @@ func (ns *Namespace) EchoParam(c, k any) any {
 			return avv.Float()
 		case reflect.String:
 			return avv.String()
+		case reflect.Bool:
+			return avv.Bool()
 		}
 	}
 


Test patch:
diff --git a/tpl/collections/integration_test.go b/tpl/collections/integration_test.go
index a059bfd26be..a443755f855 100644
--- a/tpl/collections/integration_test.go
+++ b/tpl/collections/integration_test.go
@@ -231,3 +231,37 @@ foo: bc
 	).Build()
 	b.AssertFileContent("public/index.html", "<ul><li>P1</li><li>P2</li></ul>")
 }
+
+// Issue #11498
+func TestEchoParams(t *testing.T) {
+	t.Parallel()
+	files := `
+-- hugo.toml --
+[params.footer]
+string = 'foo'
+int = 42
+float = 3.1415
+boolt = true
+boolf = false
+-- layouts/index.html --
+{{ echoParam .Site.Params.footer "string" }}
+{{ echoParam .Site.Params.footer "int" }}
+{{ echoParam .Site.Params.footer "float" }}
+{{ echoParam .Site.Params.footer "boolt" }}
+{{ echoParam .Site.Params.footer "boolf" }}
+	`
+
+	b := hugolib.NewIntegrationTestBuilder(
+		hugolib.IntegrationTestConfig{
+			T:           t,
+			TxtarString: files,
+		},
+	).Build()
+	b.AssertFileContent("public/index.html",
+		"foo",
+		"42",
+		"3.1415",
+		"true",
+		"false",
+	)
+}