--- title: Blockquote render hooks linkTitle: Blockquotes description: Create a blockquote render hook to override the rendering of Markdown blockquotes to HTML. categories: [render hooks] keywords: [] menu: docs: parent: render-hooks weight: 30 weight: 30 toc: true --- {{< new-in 0.132.0 >}} ## Context Blockquote render hook templates receive the following [context]: [context]: /getting-started/glossary/#context ###### AlertType (`string`) Applicable when [`Type`](#type) is `alert`, this is the alert type converted to lowercase. See the [alerts](#alerts) section below. ###### AlertTitle {{< new-in 0.134.0 >}} (`template.HTML`) Applicable when [`Type`](#type) is `alert`, this is the alert title. See the [alerts](#alerts) section below. ###### AlertSign {{< new-in 0.134.0 >}} (`string`) Applicable when [`Type`](#type) is `alert`, this is the alert sign. Typically used to indicate whether an alert is graphically foldable, this is one of `+`, `-`, or an empty string. See the [alerts](#alerts) section below. ###### Attributes (`map`) The [Markdown attributes], available if you configure your site as follows: [Markdown attributes]: /content-management/markdown-attributes/ {{< code-toggle file=hugo >}} [markup.goldmark.parser.attribute] block = true {{< /code-toggle >}} ###### Ordinal (`int`) The zero-based ordinal of the blockquote on the page. ###### Page (`page`) A reference to the current page. ###### PageInner (`page`) A reference to a page nested via the [`RenderShortcodes`] method. [See details](#pageinner-details). [`RenderShortcodes`]: /methods/page/rendershortcodes ###### Position (`string`) The position of the blockquote within the page content. ###### Text (`template.HTML`) The blockquote text, excluding the first line if [`Type`](#type) is `alert`. See the [alerts](#alerts) section below. ###### Type (`bool`) The blockquote type. Returns `alert` if the blockquote has an alert designator, else `regular`. See the [alerts](#alerts) section below. ## Examples In its default configuration, Hugo renders Markdown blockquotes according to the [CommonMark specification]. To create a render hook that does the same thing: [CommonMark specification]: https://spec.commonmark.org/current/ {{< code file=layouts/_default/_markup/render-blockquote.html copy=true >}}
{{ .Text }}{{< /code >}} To render a blockquote as an HTML `figure` element with an optional citation and caption: {{< code file=layouts/_default/_markup/render-blockquote.html copy=true >}}
{{ .Text }}{{ with .Attributes.caption }}
{{ else }}{{ transform.Emojify (index $emojis .AlertType) }} {{ with .AlertTitle }} {{ . }} {{ else }} {{ or (i18n .AlertType) (title .AlertType) }} {{ end }}
{{ .Text }}
{{ .Text }}{{ end }} {{< /code >}} To override the label, create these entries in your i18n files: {{< code-toggle file=i18n/en.toml >}} caution = 'Caution' important = 'Important' note = 'Note' tip = 'Tip' warning = 'Warning' {{< /code-toggle >}} Although you can use one template with conditional logic as shown above, you can also create separate templates for each [`Type`](#type) of blockquote: ```text layouts/ └── _default/ └── _markup/ ├── render-blockquote-alert.html └── render-blockquote-regular.html ``` {{% include "/render-hooks/_common/pageinner.md" %}}