Skip to content

Commit

Permalink
Miscellaneous updates for v0.140.0
Browse files Browse the repository at this point in the history
- Add configuration option: disableDefaultLanguageRedirect
- Allow collections.Querify to accept a map argument
  • Loading branch information
jmooring authored and bep committed Dec 17, 2024
1 parent 4d31952 commit fbe2d44
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion content/en/functions/collections/Dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ action:
aliases: [dict]
related:
- functions/collections/Slice
returnType: mapany
returnType: map[string]any
signatures: ['collections.Dictionary [VALUE...]']
aliases: [/functions/dict]
---
Expand Down
23 changes: 18 additions & 5 deletions content/en/functions/collections/Querify.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: collections.Querify
description: Returns a URL query string composed of the given key-value pairs.
description: Returns a URL query string composed of the given key-value pairs, encoded and sorted by key.
categories: []
keywords: []
action:
Expand All @@ -13,18 +13,18 @@ action:
aliases: [/functions/querify]
---

Specify the key-value pairs as individual arguments, or as a slice. The following are equivalent:

Specify the key-value pairs as a map, a slice, or a sequence of scalar values. For example, the following are equivalent:

```go-html-template
{{ collections.Querify "a" 1 "b" 2 }}
{{ collections.Querify (dict "a" 1 "b" 2) }}
{{ collections.Querify (slice "a" 1 "b" 2) }}
{{ collections.Querify "a" 1 "b" 2 }}
```

To append a query string to a URL:

```go-html-template
{{ $qs := collections.Querify "a" 1 "b" 2 }}
{{ $qs := collections.Querify (dict "a" 1 "b" 2) }}
{{ $href := printf "https://example.org?%s" $qs }}
<a href="{{ $href }}">Link</a>
Expand All @@ -35,3 +35,16 @@ Hugo renders this to:
```html
<a href="https://example.org?a=1&amp;b=2">Link</a>
```

You can also pass in a map from your site configuration or front matter. For example:

{{< code-toggle file=content/example.md fm=true >}}
title = 'Example'
[params.query]
a = 1
b = 2
{{< /code-toggle >}}

```go-html-template
{{ collections.Querify .Params.query }}
```
6 changes: 6 additions & 0 deletions content/en/getting-started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ To remain consistent and prevent unexpected behavior, do not mix these strategie

(`bool`) Will disable generation of alias redirects. Note that even if `disableAliases` is set, the aliases themselves are preserved on the page. The motivation with this is to be able to generate 301 redirects in an `.htaccess`, a Netlify `_redirects` file or similar using a custom output format. Default is `false`.

###### disableDefaultLanguageRedirect

{{< new-in 0.140.0 >}}

(`bool`) Disables generation of redirect to the default language when DefaultContentLanguageInSubdir is `true`. Default is `false`.

###### disableHugoGeneratorInject

(`bool`) Hugo will, by default, inject a generator meta tag in the HTML head on the _home page only_. You can turn it off, but we would really appreciate if you don't, as this is a good way to watch Hugo's popularity on the rise. Default is `false`.
Expand Down

0 comments on commit fbe2d44

Please sign in to comment.