Skip to content
Related Articles

Related Articles

Improve Article

How to set HTML meta elements with knitr ?

  • Last Updated : 15 Jul, 2021
Geek Week

Sometimes you might want to generate some R code, or any other code without wrapping it up in a <code> tag, or maybe you want to specify some elements without the specific elements. Well, the thing you need at the moment is setting up the meta elements using knitr.

The metadata means information about data. The <meta> tag in HTML provides information about HTML Document or in simple words, it provides important information about a document. These tags are basically used to add name/value pairs to describe properties of HTML documents, such as expiry date, author name, list of keywords, document author, etc. A web document can include one or more meta tags depending on information, but in general, it doesn’t affect the physical appearance of the document. 

Syntax:

<meta name="meta-name-here"<!—the knitr method—>

 



Example 1:

HTML




<!DOCTYPE html>
<html>
  
<head>
    <meta name="author" content=
          "<!--rinline I(Sys.getenv('GeeksforGeeks')) -->">
    <meta name="date" content=
          "<!--rinline I(as.character(Sys.time())) -->">
</head>
  
<body></body>
  
</html>

Example 2:

HTML




<head>
    <!--begin.rcode results='asis', echo=TRUE
    cat('
      <meta name="author" content="', 
            Sys.getenv('GeeksforGeeks'), '"> 
  
      <meta name="date" content="', 
            as.character(Sys.time()),'-->">
    ',sep="")
    end.rcode-->
</head>

Note: Both examples do not contain a body section or any displaying HTML elements, so they will not display any output result.

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :