# How are you adding citation to blockquotes?

**URL:** <https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856>\
**Category:** support\
**Created:** [December 11, 2022, 11:47am UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856 "2022-12-11T11:47:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![steppa](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@steppa](https://discourse.gohugo.io/u/steppa)\
**Post date:** [December 11, 2022, 11:47am UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856/1 "2022-12-11T11:47:51Z")

</div>

Since Hugo disables inline HTML by default, which methods are y’all using to add citation? So far, I have found the two ways below. (The second one looks more promising).

1. With a render hook

> [@Blockquote with render hook](https://discourse.gohugo.io/t/blockquote-with-render-hook/40701):
>
> I used a shortcode to generate quoteblock content. Now I switched to use a render hook. HTML blockquote can have a cite attribute. I added the author attribute. Here is it: Markdown ````quote { author="Sir Tim Berners-Lee" cite="https://cds.cern.ch/record/369245/files/dd-89-001.pdf"} Vague, but exciting… ```` layouts\_default\_markup\render-codeblock-quote.html {{ $author := .Attributes.author }} {{ $cite := .Attributes.cite }} \<figure\> \<blockquote {{ with $cite }} cite="{{.| safeH…

1. With `replaceRE`

> [@Get missing inline HTML tags in Markdown without enabling HTML](https://discourse.gohugo.io/t/get-missing-inline-html-tags-in-markdown-without-enabling-html/40234):
>
> Hi, Goldmark lacks formatting signs for a few inline HTML tags. We can enable HTML to use them in our Markdown, but this is not a good solution, where security should be a concern — e.g. for themes or larger projects with many contributors. The site configuration parameter unsafe should be left in its default state unsafe = false. In the last few month, I’ve found the following replacements very useful to inject some missing HTML tags after Goldmark has rendered the HTML. So far, there was no …

---

<div class="post-metadata">

**Author:** ![ju52](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ju52/32/6749_2.png) [@ju52](https://discourse.gohugo.io/u/ju52)\
**Post date:** [December 11, 2022, 12:04pm UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856/2 "2022-12-11T12:04:41Z")

</div>

I think you want to show HTML?

in the MD files:

`````
```HTML
<link rel=stylesheet href=/dark.css media="(prefers-color-scheme: dark)">
<link rel=stylesheet href=/light.css media="(prefers-color-scheme: light)">
<link rel=stylesheet href=/main.css>
````

`````

my **render-codeblock.html**

```auto
{{ $class := .Attributes.class | default "" }}
{{ $lang := .Attributes.lang | default .Type }}
{{ if transform.CanHighlight $lang }}
<div class="code {{ $class }}">{{ highlight .Inner $lang }}</div>
{{else}}
<pre><code class=" code {{ $class }}">{{.Inner}}</code></pre>
{{end}}

```

sometimes I use a shortcode to insert a file

```auto
<div>
  {{ $file := .Page.File.Path }}
  {{ $lang := path.Ext .Page.File.Path }}
  {{ if gt (len .Params) 0 -}}
  {{ $lang = .Get 1 | default "text"}}
  {{ $file = .Get 0 }}
  {{- end -}}
  {{ $file = readFile $file }}
  {{ highlight $file $lang "linenos=table" }}
</div>

```

hope this help to find your solution

---

<div class="post-metadata">

**Author:** ![steppa](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@steppa](https://discourse.gohugo.io/u/steppa)\
**Post date:** [December 11, 2022, 1:40pm UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856/3 "2022-12-11T13:40:45Z")

</div>

> [@ju52](#):
>
> I think you want to show HTML?

No. But to include `<cite>lorem ipsum</cite>` in my blockquotes where applicable without enabling `unsafe: true` in the markdown parser.

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [December 11, 2022, 2:39pm UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856/4 "2022-12-11T14:39:31Z")

</div>

I asked once to create a markup-render-hook for `blockquote` but it was somehow swatted down as not something the system needs. So I created my own shortcode for this. There is no Markdown-way to add cite attributes to blockquote tags. I did not “re-visit” the issue for some years now, it might have changed. My shortcode is the following setup:

[`layouts/shortcodes/quote.html`](https://github.com/davidsneighbour/hugo-shortcodes/blob/main/layouts/shortcodes/quote.html)

```go-template
<blockquote class="blockquote">
	{{.Inner}}
    {{ if .Get "source" }}
    <footer class="blockquote-footer">
		<cite title="Quelle: {{ with .Get "source"}}{{.}}{{ end }}">
            {{ with .Get "src"}}
                Weiterlesen auf
                <a href="{{.}}" target="_blank" rel="noopener noreferrer">
            {{ end }}
            {{ with .Get "source" }}{{.}}{{ end }}
            {{ with .Get "src"}}
                </a>
            {{ end }}
		</cite>
	</footer>
    {{ end }}
</blockquote>

```

call this in your markdown files via:

```auto
Something something

{{< quote source="the guy who said it" src="https://alinktotheguywhosaidit.com" >}}
the quote
{{< /quote >}}

```

There are some optimizations in there (like the src-attribute for an URL and (my fault), plenty of German phrases), so you probably want to re-create the shortcode instead of just copying it.

It’s more work, but this is the way Hugo can add cite tags to your blockquotes (for now), because… it can’t (add cite tags to your blockquotes).

---

<div class="post-metadata">

**Author:** ![steppa](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@steppa](https://discourse.gohugo.io/u/steppa)\
**Post date:** [December 11, 2022, 3:26pm UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856/5 "2022-12-11T15:26:09Z")

</div>

I will take this for a spin.

---

<div class="post-metadata">

**Author:** ![Mehdi\_Saada](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mehdi_saada/32/16885_2.png) [@Mehdi\_Saada](https://discourse.gohugo.io/u/Mehdi_Saada)\
**Post date:** [December 12, 2022, 6:51pm UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856/6 "2022-12-12T18:51:21Z")

</div>

what’s wrong with your render hook ? I found it genius, and adopted it.

---

<div class="post-metadata">

**Author:** ![steppa](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@steppa](https://discourse.gohugo.io/u/steppa)\
**Post date:** [December 12, 2022, 9:03pm UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856/8 "2022-12-12T21:03:19Z")

</div>

I went with this option after much testing

> [@Get missing inline HTML tags in Markdown without enabling HTML](https://discourse.gohugo.io/t/get-missing-inline-html-tags-in-markdown-without-enabling-html/40234):
>
> Hi, Goldmark lacks formatting signs for a few inline HTML tags. We can enable HTML to use them in our Markdown, but this is not a good solution, where security should be a concern — e.g. for themes or larger projects with many contributors. The site configuration parameter unsafe should be left in its default state unsafe = false. In the last few month, I’ve found the following replacements very useful to inject some missing HTML tags after Goldmark has rendered the HTML. So far, there was no …

---

<div class="post-metadata">

**Author:** ![Mehdi\_Saada](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mehdi_saada/32/16885_2.png) [@Mehdi\_Saada](https://discourse.gohugo.io/u/Mehdi_Saada)\
**Post date:** [December 12, 2022, 11:50pm UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856/9 "2022-12-12T23:50:58Z")

</div>

security issue ?  
I can understand, I needed the unsafe setting to add \<cite\> and \<q\>. But how does it relate with the render hook method ? No need for `unsafe = true` and it’s much more elegant than using shortcodes

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [December 12, 2022, 11:55pm UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856/10 "2022-12-12T23:55:57Z")

</div>

Please read this:  
[https://gohugo.io/about/security-model/#web-application-security](https://gohugo.io/about/security-model/#web-application-security)

> Templates authors (you) are trusted, but the data you send in is not.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [December 13, 2022, 12:02am UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856/11 "2022-12-13T00:02:21Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [December 15, 2022, 12:02am UTC](https://discourse.gohugo.io/t/how-are-you-adding-citation-to-blockquotes/41856/12 "2022-12-15T00:02:37Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
