1

I'm using hugo as packaged in Debian, using the default renderer (goldmark) and the kube theme.

$ hugo version
Hugo Static Site Generator v0.78.2/extended linux/amd64 BuildDate: 2020-11-16T11:43:13Z

I would like include a hyperlink to a text that includes angle brackets.

something like:

[`https://example.com/<slug>`](https://example.com/)

which should come out like https://example.com/<slug> (and which is working properly here on StackOverflow).

However, with hugo, that same input renders (as shown in the browser) as:

 <code>https://example.com/&lt;slug&gt;</code>

btw, the above string is hyperlinked to https://example.com/, so that part is working.

without `

I wouldn't mind leaving out the code-formatting, but it doesn't work either (and produces a different, but still wrong, output).

The input is:

[https://example.com/<slug>](https://example.com/)

Whereas the hugo-rendered output is (as shown in the browser):

 https://example.com/<!-- raw HTML omitted --> 

(btw, StackOverflow renders this as https://example.com/, so it seems to not work anyhow...)

with &lt; and &gt;

I also tried:

[http://example.com/&lt;slug&gt;](http://example.com/)

But that renders as:

 http://example.com/&lt;slug&gt; 

?

So how would I proceed to crate "https://example.com/<slug>" in hugo.

umläute
  • 28,885
  • 9
  • 68
  • 122
  • 3
    Does this answer your question? [Hugo shortcode ignored saying "raw HTML omitted"](https://stackoverflow.com/questions/63198652/hugo-shortcode-ignored-saying-raw-html-omitted) – Thomas Hansen Dec 23 '20 at 11:14

1 Answers1

1

Please refer to this answer https://stackoverflow.com/a/63206852. If you use a config.yaml, it should include:

markup:
  goldmark:
    renderer:
      unsafe: true

A config.tomlversion should be:

[markup]
  [markup.goldmark]
    [markup.goldmark.renderer]
      unsafe = true

In that case

[http://example.com/&lt;slug&gt;](http://example.com/)

will work.

Explanation: In the Hugo documentation (see https://gohugo.io/getting-started/configuration-markup#goldmark) the explanation of unsafe mode says that:

By default, Goldmark does not render raw HTMLs and potentially dangerous links. If you have lots of inline HTML and/or JavaScript, you may need to turn this on.

More information about unsafe characters in URLs can be found in the RFC 1738, Uniform Resource Locators specification, p. 2.

Community
  • 1
  • 1
Thomas Hansen
  • 775
  • 1
  • 6
  • 17
  • actually i'd rather not enable unsafe rendering for all pages, just because the renderer chooses to expand my `<` to `<` but then shies away from rendering the expanded string. i don't really think that `https://example.com/` is either "raw HTML" nor "potentially dangerous" (or both). – umläute Dec 23 '20 at 12:39
  • @umläute - That's perfectly fine, but then you should probably modify your question, so that unsafe mode is not allowed. As it stands, it's still a valid answer to your question. – Thomas Hansen Dec 23 '20 at 12:56
  • yes certainly... – umläute Dec 23 '20 at 12:59