Title: | HTML Metadata Tags for 'R Markdown' and 'Shiny' |
---|---|
Description: | Create meta tags for 'R Markdown' HTML documents and 'Shiny' apps for customized social media cards, for accessibility, and quality search engine indexing. 'metathis' currently supports HTML documents created with 'rmarkdown', 'shiny', 'xaringan', 'pagedown', 'bookdown', and 'flexdashboard'. |
Authors: | Garrick Aden-Buie [aut, cre] |
Maintainer: | Garrick Aden-Buie <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.4.9000 |
Built: | 2024-08-12 04:18:35 UTC |
Source: | https://github.com/gadenbuie/metathis |
Use include_meta()
to explicitly declare the meta()
tags as an HTML
dependency. In general, this is not required when knitting to an HTML
document. This function explicitly attaches an htmltools::htmlDependency()
and may work in some unusual cases.
include_meta(.meta)
include_meta(.meta)
.meta |
A |
An htmltools::htmlDependency()
containing the metadata tags to be
included in the <head>
of the HTML document.
Other meta_actions:
write_meta()
meta() %>% meta_name("github-repo" = "gadenbuie/metathis") %>% include_meta()
meta() %>% meta_name("github-repo" = "gadenbuie/metathis") %>% include_meta()
Initialize a metathis object (i.e. a list of HTML metadata tags), test if
an object is a metathis object, or coerce a list of meta
tags to be a
metathis object.
meta() is_meta(x) as_meta(x)
meta() is_meta(x) as_meta(x)
x |
A list or metathis object |
A meta
object, or a set of <meta>
HTML tags inside an HTML
<head>
tag. For use in rmarkdown::html_document()
, shiny::runApp()
,
or other HTML locations.
is_meta()
: Test if an objects is a metathis object
as_meta()
: Convert a list of meta tags into a metathis object.
Other meta:
meta_apple_itunes_app()
,
meta_apple_web_app()
,
meta_general()
,
meta_geo()
,
meta_google_scholar()
,
meta_name()
,
meta_social()
,
meta_tag()
,
meta_viewport()
meta() %>% meta_viewport() %>% is_meta() list_of_meta_tags <- list( htmltools::tags$meta(github = "gadenbuie"), htmltools::tags$meta(twitter = "grrrck") ) as_meta(list_of_meta_tags)
meta() %>% meta_viewport() %>% is_meta() list_of_meta_tags <- list( htmltools::tags$meta(github = "gadenbuie"), htmltools::tags$meta(twitter = "grrrck") ) as_meta(list_of_meta_tags)
Apple Smart Banner Meta Tag
meta_apple_itunes_app(.meta = meta(), app_id = NULL, affiliate_id = NULL, ...)
meta_apple_itunes_app(.meta = meta(), app_id = NULL, affiliate_id = NULL, ...)
.meta |
A |
app_id |
Apple app ID |
affiliate_id |
Apple affiliate ID |
... |
Additional name=value pairs. |
A meta
object, or a set of <meta>
HTML tags inside an HTML
<head>
tag. For use in rmarkdown::html_document()
, shiny::runApp()
,
or other HTML locations.
# <!-- Smart App Banner --> <meta name="apple-itunes-app" content="app-id=APP_ID,affiliate-data=AFFILIATE_ID,app-argument=SOME_TEXT">
Other meta:
meta_apple_web_app()
,
meta_general()
,
meta_geo()
,
meta_google_scholar()
,
meta_name()
,
meta_social()
,
meta_tag()
,
meta_viewport()
,
meta()
Apple Web App Meta Tags
meta_apple_web_app( .meta = meta(), title = NULL, capable = NULL, status_bar_style = c("default", "black", "black-translucent") )
meta_apple_web_app( .meta = meta(), title = NULL, capable = NULL, status_bar_style = c("default", "black", "black-translucent") )
.meta |
A |
title |
Launch Icon Title |
capable |
Enables standalone (full-screen) mode if TRUE |
status_bar_style |
Status bar appearance. has no effect unless
standalone more is enabled (see "If content is set to default, the status bar appears normal. If set to black, the status bar has a black background. If set to black-translucent, the status bar is black and translucent. If set to default or black, the web content is displayed below the status bar. If set to black-translucent, the web content is displayed on the entire screen, partially obscured by the status bar. The default value is default." |
A meta
object, or a set of <meta>
HTML tags inside an HTML
<head>
tag. For use in rmarkdown::html_document()
, shiny::runApp()
,
or other HTML locations.
Other meta:
meta_apple_itunes_app()
,
meta_general()
,
meta_geo()
,
meta_google_scholar()
,
meta_name()
,
meta_social()
,
meta_tag()
,
meta_viewport()
,
meta()
meta() %>% meta_apple_web_app( title = "My Fancy App", capable = TRUE, status_bar_style = "black-translucent" )
meta() %>% meta_apple_web_app( title = "My Fancy App", capable = TRUE, status_bar_style = "black-translucent" )
Generate metadata tags for general website properties.
meta_general( .meta = meta(), application_name = NULL, theme_color = NULL, description = NULL, robots = NULL, generator = NULL, subject = NULL, rating = NULL, referrer = NULL ) meta_description(.meta = meta(), description) meta_subject(.meta = meta(), subject) meta_referrer(.meta = meta(), referrer) meta_robots(.meta = meta(), robots) meta_theme_color(.meta = meta(), theme_color)
meta_general( .meta = meta(), application_name = NULL, theme_color = NULL, description = NULL, robots = NULL, generator = NULL, subject = NULL, rating = NULL, referrer = NULL ) meta_description(.meta = meta(), description) meta_subject(.meta = meta(), subject) meta_referrer(.meta = meta(), referrer) meta_robots(.meta = meta(), robots) meta_theme_color(.meta = meta(), theme_color)
.meta |
A |
application_name |
Name of web application (only should be used if the website is used as an app). |
theme_color |
Theme Color for Chrome, Firefox OS and Opera, e.g.
|
description |
Short description of the document (limit to 150 characters), This content may be used as a part of search engine results. |
robots |
Control the behavior of search engine crawling and indexing,
e.g. See https://www.robotstxt.org/meta.html for more information. |
generator |
Identify the software used to build the document (i.e. - WordPress, Dreamweaver). |
subject |
Short description of your document's subject. |
rating |
Gives a general age rating based on the document's content,
e.g. |
referrer |
Allows control over how referrer information is passed, .e.g.
|
A meta
object, or a set of <meta>
HTML tags inside an HTML
<head>
tag. For use in rmarkdown::html_document()
, shiny::runApp()
,
or other HTML locations.
Other meta:
meta_apple_itunes_app()
,
meta_apple_web_app()
,
meta_geo()
,
meta_google_scholar()
,
meta_name()
,
meta_social()
,
meta_tag()
,
meta_viewport()
,
meta()
meta() %>% meta_general( application_name = "Application Name", theme_color = "#4285f4", description = "A description of this page", robots = "index,follow", generator = "R-Shiny", subject = "Awesome R projects", rating = "General", referrer = "no-referrer" )
meta() %>% meta_general( application_name = "Application Name", theme_color = "#4285f4", description = "A description of this page", robots = "index,follow", generator = "R-Shiny", subject = "Awesome R projects", rating = "General", referrer = "no-referrer" )
Geotagging Metadata Tags
meta_geo( .meta = meta(), icbm = NULL, geo_position = NULL, geo_region = NULL, geo_placename = NULL, ... )
meta_geo( .meta = meta(), icbm = NULL, geo_position = NULL, geo_region = NULL, geo_placename = NULL, ... )
.meta |
A |
icbm |
Latitude and longitude of geographic positions specified as
|
geo_position |
Latitude and longitude of geographic positions specified
as |
geo_region |
Name of the geographic region related to the page content,
specified using ISO-3166
2-character country code and 2-character national subdivision. Example:
|
geo_placename |
Name of the geographic place related to the page
content. Example: |
... |
Additional geotagging metadata keyword and value pairs, such as
|
A meta
object, or a set of <meta>
HTML tags inside an HTML
<head>
tag. For use in rmarkdown::html_document()
, shiny::runApp()
,
or other HTML locations.
ICBM on Wikipedia, Geotagging on Wikipedia
Other meta:
meta_apple_itunes_app()
,
meta_apple_web_app()
,
meta_general()
,
meta_google_scholar()
,
meta_name()
,
meta_social()
,
meta_tag()
,
meta_viewport()
,
meta()
meta() %>% meta_geo( icbm = c(50.167958, -97.133185), geo_position = c(50.167958, -97.133185), geo_placename = "Manitoba, Canada", geo_region = "ca-mb" )
meta() %>% meta_geo( icbm = c(50.167958, -97.133185), geo_position = c(50.167958, -97.133185), geo_placename = "Manitoba, Canada", geo_region = "ca-mb" )
Add bibliographic metadata to pages in the format expected by Google
Scholar. Please reference the
Google Scholar Inclusion
page for the most up-to-date information and instructions. Note that this
function adds the citation_
prefix to all of its arguments; the title
argument becomes the citation_title
<meta>
tag.
meta_google_scholar( .meta = meta(), title, author, publication_date, online_date = NULL, journal_title = NULL, conference_title = NULL, volume = NULL, issue = NULL, firstpage = NULL, lastpage = NULL, pdf_url = NULL, issn = NULL, isbn = NULL, dissertation_institution = NULL, technical_report_institution = NULL, technical_report_number = NULL )
meta_google_scholar( .meta = meta(), title, author, publication_date, online_date = NULL, journal_title = NULL, conference_title = NULL, volume = NULL, issue = NULL, firstpage = NULL, lastpage = NULL, pdf_url = NULL, issn = NULL, isbn = NULL, dissertation_institution = NULL, technical_report_institution = NULL, technical_report_number = NULL )
.meta |
A |
title |
The title of the paper. The title tag must contain the title of the paper. Don't use it for the title of the journal or a book in which the paper was published, or for the name of your repository. This tag is required for inclusion in Google Scholar. |
author |
A vector of author names. The |
publication_date , online_date
|
The date the paper was published in the
journal ( The |
journal_title , conference_title , issn , isbn , volume , issue , firstpage , lastpage
|
For journal and conference papers, provide the remaining bibliographic
citation data in the following tags: |
pdf_url |
The |
dissertation_institution , technical_report_institution , technical_report_number
|
For theses, dissertations, and technical reports, provide the remaining
bibliographic citation data in the following tags:
|
A meta
object, or a set of <meta>
HTML tags inside an HTML
<head>
tag. For use in rmarkdown::html_document()
, shiny::runApp()
,
or other HTML locations.
https://scholar.google.com/intl/en/scholar/inclusion.html#indexing
Other meta:
meta_apple_itunes_app()
,
meta_apple_web_app()
,
meta_general()
,
meta_geo()
,
meta_name()
,
meta_social()
,
meta_tag()
,
meta_viewport()
,
meta()
meta_google_scholar( title = c( "The testis isoform of the phosphorylase kinase catalytic subunit (PhK-T)", "plays a critical role in regulation of glycogen mobilization in developing lung" ), author = c( "Liu, Li", "Rannels, Stephen R.", "Falconieri, Mary", "Phillips, Karen S.", "Wolpert, Ellen B.", "Weaver, Timothy E." ), publication_date = "1996/05/17", journal_title = "Journal of Biological Chemistry", volume = 271, issue = 20, firstpage = 11761, lastpage = 11766, pdf_url = "http://www.example.com/content/271/20/11761.full.pdf" )
meta_google_scholar( title = c( "The testis isoform of the phosphorylase kinase catalytic subunit (PhK-T)", "plays a critical role in regulation of glycogen mobilization in developing lung" ), author = c( "Liu, Li", "Rannels, Stephen R.", "Falconieri, Mary", "Phillips, Karen S.", "Wolpert, Ellen B.", "Weaver, Timothy E." ), publication_date = "1996/05/17", journal_title = "Journal of Biological Chemistry", volume = 271, issue = 20, firstpage = 11761, lastpage = 11766, pdf_url = "http://www.example.com/content/271/20/11761.full.pdf" )
Creates metadata tag pairs where the arguments are the name values and their values are content values.
meta_name(.meta = meta(), ...)
meta_name(.meta = meta(), ...)
.meta |
A |
... |
Name (argument names) and content (argument value) pairs. |
A meta
object, or a set of <meta>
HTML tags inside an HTML
<head>
tag. For use in rmarkdown::html_document()
, shiny::runApp()
,
or other HTML locations.
Other meta:
meta_apple_itunes_app()
,
meta_apple_web_app()
,
meta_general()
,
meta_geo()
,
meta_google_scholar()
,
meta_social()
,
meta_tag()
,
meta_viewport()
,
meta()
meta() %>% meta_name("github-repo" = "hadley/r4ds")
meta() %>% meta_name("github-repo" = "hadley/r4ds")
Generate metadata tags for social media cards.
meta_social( .meta = meta(), title = NULL, url = NULL, image = NULL, image_alt = NULL, image_width = NULL, image_height = NULL, description = NULL, twitter_card_type = c("summary", "summary_large_image", "app", "player"), twitter_creator = NULL, twitter_site = twitter_creator, og_type = "website", og_locale = "en_US", og_author = NULL, og_site_name = NULL, facebook_app_id = NULL, disable_pinterest = FALSE )
meta_social( .meta = meta(), title = NULL, url = NULL, image = NULL, image_alt = NULL, image_width = NULL, image_height = NULL, description = NULL, twitter_card_type = c("summary", "summary_large_image", "app", "player"), twitter_creator = NULL, twitter_site = twitter_creator, og_type = "website", og_locale = "en_US", og_author = NULL, og_site_name = NULL, facebook_app_id = NULL, disable_pinterest = FALSE )
.meta |
A |
title |
Content title |
url |
Content URL |
image |
Image url for card. |
image_alt |
A description of what's in the image (not a caption) |
image_width |
The width of the image in pixels |
image_height |
The height of the image in pixels |
description |
Content description. If you have already used
|
twitter_card_type |
One of |
twitter_creator |
|
twitter_site |
|
og_type |
Open Graph card type, default is |
og_locale |
The locale these tags are marked up in. Of the format |
og_author |
Writers of the article. Multiple authors may be specified in a vector of character strings. |
og_site_name |
The name of the site hosting the content |
facebook_app_id |
The Facebook app ID. See the Facebook Open Graph Markup page for more information. |
disable_pinterest |
If |
A meta
object, or a set of <meta>
HTML tags inside an HTML
<head>
tag. For use in rmarkdown::html_document()
, shiny::runApp()
,
or other HTML locations.
Other meta:
meta_apple_itunes_app()
,
meta_apple_web_app()
,
meta_general()
,
meta_geo()
,
meta_google_scholar()
,
meta_name()
,
meta_tag()
,
meta_viewport()
,
meta()
meta() %>% meta_social( title = "R for Data Science", description = "This book with teach you how to do data science with R", url = "https://r4ds.had.co.nz", image = "https://r4ds.had.co.nz/cover.png", image_alt = "The cover of the R4DS book", og_type = "book", og_author = c("Garrett Grolemund", "Hadley Wickham"), twitter_card_type = "summary", twitter_creator = "@hadley" )
meta() %>% meta_social( title = "R for Data Science", description = "This book with teach you how to do data science with R", url = "https://r4ds.had.co.nz", image = "https://r4ds.had.co.nz/cover.png", image_alt = "The cover of the R4DS book", og_type = "book", og_author = c("Garrett Grolemund", "Hadley Wickham"), twitter_card_type = "summary", twitter_creator = "@hadley" )
Creates a <meta>
tag for attribute value pairs, where argument names
correspond to attribute names.
meta_tag(.meta = meta(), ...)
meta_tag(.meta = meta(), ...)
.meta |
A |
... |
Attribute names and values as |
A meta
object, or a set of <meta>
HTML tags inside an HTML
<head>
tag. For use in rmarkdown::html_document()
, shiny::runApp()
,
or other HTML locations.
Other meta:
meta_apple_itunes_app()
,
meta_apple_web_app()
,
meta_general()
,
meta_geo()
,
meta_google_scholar()
,
meta_name()
,
meta_social()
,
meta_viewport()
,
meta()
meta() %>% meta_tag( "http-equiv" = "Content-Security-Policy", content = "default-src 'self'" )
meta() %>% meta_tag( "http-equiv" = "Content-Security-Policy", content = "default-src 'self'" )
Create or add a viewport meta tag.
meta_viewport( .meta = meta(), width = "device-width", initial_scale = "1", orientation = c("auto", "portrait", "landscape"), min_width = NULL, max_width = NULL, height = NULL, min_height = NULL, max_height = NULL, minimum_scale = NULL, maximum_scale = NULL, user_scalable = NULL, ... )
meta_viewport( .meta = meta(), width = "device-width", initial_scale = "1", orientation = c("auto", "portrait", "landscape"), min_width = NULL, max_width = NULL, height = NULL, min_height = NULL, max_height = NULL, minimum_scale = NULL, maximum_scale = NULL, user_scalable = NULL, ... )
.meta |
A |
width |
Sets the width of initial viewport. |
initial_scale |
Initial scale |
orientation |
One of |
min_width , max_width
|
Minimum and maximum initial viewport width. See
|
height , min_height , max_height
|
Sets height of initial viewport. Follows
the same conventions as |
minimum_scale |
Minimum scale |
maximum_scale |
Maximum scale |
user_scalable |
User scalable |
... |
Additional name/value pairs |
A meta
object, or a set of <meta>
HTML tags inside an HTML
<head>
tag. For use in rmarkdown::html_document()
, shiny::runApp()
,
or other HTML locations.
Other meta:
meta_apple_itunes_app()
,
meta_apple_web_app()
,
meta_general()
,
meta_geo()
,
meta_google_scholar()
,
meta_name()
,
meta_social()
,
meta_tag()
,
meta()
meta() %>% meta_viewport() meta() %>% meta_viewport(orientation = NULL) meta() %>% meta_viewport(maximum_scale = 1)
meta() %>% meta_viewport() meta() %>% meta_viewport(orientation = NULL) meta() %>% meta_viewport(maximum_scale = 1)
Write your metadata tags to an HTML file that can be manually included in your page.
write_meta(.meta, path = "meta.html", append = FALSE)
write_meta(.meta, path = "meta.html", append = FALSE)
.meta |
A |
path |
The file to write into, defaults to |
append |
logical. Only used if the argument |
Returns .meta
invisibly.
Other meta_actions:
include_meta()
meta_html_snippet <- tempfile("metathis_example", fileext = ".html") meta() %>% meta_name("package" = "metathis") %>% write_meta(meta_html_snippet) readLines(meta_html_snippet, warn = FALSE)
meta_html_snippet <- tempfile("metathis_example", fileext = ".html") meta() %>% meta_name("package" = "metathis") %>% write_meta(meta_html_snippet) readLines(meta_html_snippet, warn = FALSE)