The qr
shortcode encodes the given text into a [QR code] using the specified options and renders the resulting image.
Internally this shortcode calls the images.QR
function. Please read the [related documentation] for implementation details and guidance.
Examples #
Use the self-closing syntax to pass the text as an argument:
{{< qr text="https://gohugo.io" />}}
Or insert the text between the opening and closing tags:
{{< qr >}}
https://gohugo.io
{{< /qr >}}
Both of the above produce this image:
To create a QR code for a phone number:
{{< qr text="tel:+12065550101" />}}
To create a QR code containing contact information in the [vCard] format:
{{< qr level="low" scale=2 alt="QR code of vCard for John Smith" >}}
BEGIN:VCARD
VERSION:2.1
N;CHARSET=UTF-8:Smith;John;R.;Dr.;PhD
FN;CHARSET=UTF-8:Dr. John R. Smith, PhD.
ORG;CHARSET=UTF-8:ABC Widgets
TITLE;CHARSET=UTF-8:Vice President Engineering
TEL;TYPE=WORK:+12065550101
EMAIL;TYPE=WORK:jsmith@example.org
END:VCARD
{{< /qr >}}
BEGIN:VCARD VERSION:2.1 N;CHARSET=UTF-8:Smith;John;R.;Dr.;PhD FN;CHARSET=UTF-8:Dr. John R. Smith, PhD. ORG;CHARSET=UTF-8:ABC Widgets TITLE;CHARSET=UTF-8:Vice President Engineering TEL;TYPE=WORK:+12065550101 EMAIL;TYPE=WORK:jsmith@example.org END:VCARD
Parameters #
- text
- (
string
) The text to encode, falling back to the text between the opening and closing shortcode tags. - level
- (
string
) The error correction level to use when encoding the text, one oflow
,medium
,quartile
, orhigh
. Default ismedium
. - scale
- (
int
) The number of image pixels per QR code module. Must be greater than or equal to 2. Default is4
. - targetDir
- (
string
) The subdirectory within the [publishDir
] where Hugo will place the generated image. - alt
- (
string
) Thealt
attribute of theimg
element. - class
- (
string
) Theclass
attribute of theimg
element. - id
- (
string
) Theid
attribute of theimg
element. - title
- (
string
) Thetitle
attribute of theimg
element.