8

How do I turn off the title in an Rmd HTML document?

---
title: ""
output: html_document
---

rmarkdown::render("index.Rmd")

[WARNING] This document format requires a nonempty element. Please specify either 'title' or 'pagetitle' in the metadata. Falling back to 'index.utf8'

Looking for a quick easy fix without having to modify the underlying template.

1
  • 2
    Note that the document is actually created without a title, despite the warning... the 'title' mentioned in the warning is in fact the html's title tag, i.e. the text that is shown in the browser tab. It can be also set independently of the document title via "pagetitle" yaml element
    – Max
    Mar 11, 2021 at 15:20

2 Answers 2

10

This creates a blank page.

---
title: " "
output: html_document
---

Further, it might be the case that " " adds unwanted white space to the top of the corresponding webpage. Using " " does the same thing without adding the potential white space.

For background, &...; are known as "entities" in HTML language, with   being an entity name standing for "non-breaking space" while   is an entity code indicating a "space." More description and other entities can be found here, for example: https://www.w3schools.com/html/html_entities.asp

2

Having a blank title is not ideal, because then the html page lacks the "title" metadata. What you probably want instead is just to not display the title. To do that, create a css file containing:

#header {
    display: none;
}

and then insert a reference to that css file in the YAML:

---
title: My title
css: style.css
---

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.