How to force pandoc not to build <a> tag when url is in YAML metadata

Viewed 423

Let's say we have simple empty .Rmd file with YAML metadata like this

---
link: https://google.com
---

Then in html template, it will show up automatically in <a> tag

<a href="http://google.com" class="uri">http://google.com</a>

How to force pandoc not to build <a> when there is url in YAML? I mean what I wanna finally get is plan text in html template

http://google.com

Or if I use own html template I can add a link that way

<a href="$link$">Google</a>

Thanks for help!

2 Answers

This is caused by an extension that is enabled by default with the md_extensions option under the output format, specifically auto_link_bare_uris. You can disable this in your YAML header.

---
title: https://www.google.com
output:
  html_document:
    md_extensions: -autolink_bare_uris
---

Just note that this will affect auto linking of URIs throughout your document, not only in the title. After disabling the extension you will need to enclose links in angle brackets to create links, i.e. <https://www.google.com>. The Pandoc guide and the R Markdown site contain the detail covering this.

Replacing a character in the title with an HTML ASCII reference will stop the link from auto generating and display on the page correctly. For example, here I replace the colon:

---
title: https&#58;//gooogle.com
---
Related