Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'

This commit is contained in:
Bjørn Erik Pedersen
2025-04-10 13:04:51 +02:00
987 changed files with 12379 additions and 14083 deletions

View File

@@ -2,13 +2,11 @@
title: images.QR
description: Encodes the given text into a QR code using the specified options, returning an image resource.
keywords: []
action:
aliases: []
related: []
returnType: images.ImageResource
signatures: ['images.QR TEXT [OPTIONS]']
toc: true
math: true
params:
functions_and_methods:
aliases: []
returnType: images.ImageResource
signatures: ['images.QR TEXT [OPTIONS]']
---
{{< new-in 0.141.0 />}}
@@ -21,19 +19,17 @@ The `images.QR` function encodes the given text into a [QR code] using the speci
Although the default option values are sufficient for most applications, you should test the rendered QR code both on-screen and in print.
[QR code]: https://en.wikipedia.org/wiki/QR_code
## Options
level
: (`string`) The error correction level to use when encoding the text, one of `low`, `medium`, `quartile`, or `high`. Default is `medium`.
Error correction level|Redundancy
:--|:--|:--
low|20%
medium|38%
quartile|55%
high|65%
Error correction level|Redundancy
:--|:--|:--
low|20%
medium|38%
quartile|55%
high|65%
scale
: (`int`) The number of image pixels per QR code module. Must be greater than or equal to `2`. Default is `4`.
@@ -41,8 +37,6 @@ scale
targetDir
: (`string`) The subdirectory within the [`publishDir`] where Hugo will place the generated image. Use Unix-style slashes (`/`) to separarate path segments. If empty or not provided, the image is placed directly in the `publishDir` root. Hugo automatically creates the necessary subdirectories if they don't exist.
[`publishDir`]: /getting-started/configuration/#publishdir
## Examples
To create a QR code using the default values for `level` and `scale`:
@@ -74,7 +68,7 @@ Specify `level`, `scale`, and `targetDir` as needed to achieve the desired resul
To include a QR code that points to the `Permalink` of the current page:
{{< code file=layouts/_default/single.html >}}
```go-html-template {file="layouts/_default/single.html"}
{{ with images.QR .Permalink }}
<img
src="{{ .RelPermalink }}"
@@ -85,7 +79,7 @@ To include a QR code that points to the `Permalink` of the current page:
loading="lazy"
>
{{ end }}
{{< /code >}}
```
Then hide the QR code with CSS unless printing the page:
@@ -116,9 +110,8 @@ If the QR code will be printed, use the default `scale` value of `4` pixels per
Avoid using Hugo's image processing methods to resize QR codes. Resizing can introduce blurring due to anti-aliasing when a QR code module occupies a fractional number of pixels.
{{% note %}}
Always test the rendered QR code both on-screen and in print.
{{% /note %}}
> [!note]
> Always test the rendered QR code both on-screen and in print.
## Shortcode
@@ -140,4 +133,6 @@ https://gohugo.io
The `qr` shortcode accepts several arguments including `level` and `scale`. See the [related documentation] for details.
[`publishDir`]: /configuration/all/#publishdir
[QR code]: https://en.wikipedia.org/wiki/QR_code
[related documentation]: /shortcodes/qr/