| Title: | Search Engine Optimization, Social Metadata, and Site Verification Helpers for 'Shiny' Apps |
|---|---|
| Description: | Utilities for injecting search engine optimization (SEO), Open Graph, Twitter, site verification, and schema.org metadata into 'Shiny' applications from YAML files or named lists. |
| Authors: | Rolf Lindgren [aut, cre] |
| Maintainer: | Rolf Lindgren <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.2.0 |
| Built: | 2026-06-08 14:50:40 UTC |
| Source: | https://github.com/rolfmblindgren/shinyseo |
Looks for missing favicon, Apple touch icon, and share image fields in
meta and asks a caller-supplied generator function to create
them. shinyseo does not call any image-generation service itself –
generator is the caller's own function, written against whatever
LLM or image-generation API they already have access to (OpenAI, Adobe
Firefly, a local model, and so on). This keeps the package free of any
particular vendor's dependencies, API keys, formats, or running costs –
the caller's function is the only thing that needs to know which service
it is talking to.
generate_assets( meta, generator, path = "www", assets = c("favicon", "apple_touch_icon", "image") )generate_assets( meta, generator, path = "www", assets = c("favicon", "apple_touch_icon", "image") )
meta |
Either a path to a YAML file or a named list, as for
|
generator |
A function taking |
path |
Directory to write generated files into. Defaults to
|
assets |
Character vector naming which fields to fill in if missing.
Defaults to all three: |
The updated meta list, with newly generated fields set to
paths under path (e.g. "/favicon.png"). Fields already
present in meta are left untouched. Write the result back with
yaml::write_yaml() to persist it.
Walks through the fields used by social_meta() and
write_manifest() at the console and writes the answers to a YAML
file. Meant as a quick on-ramp so new users can get a working
meta.yml without first reading the field reference.
init_meta(path = "meta.yml")init_meta(path = "meta.yml")
path |
File to write the metadata to. Defaults to |
The path to the written file, invisibly.
Returns a function suitable for the generator argument of
generate_assets(). The returned function calls OpenAI's image
generation endpoint and hands back the raw image bytes, so
generate_assets() can write them straight to disk.
openai_image_generator(api_key = Sys.getenv("OPENAI_API_KEY"), model = "gpt-image-1")openai_image_generator(api_key = Sys.getenv("OPENAI_API_KEY"), model = "gpt-image-1")
api_key |
OpenAI API key. Defaults to the |
model |
OpenAI image model to call. Defaults to |
This is the only built-in generator shinyseo ships. It exists because
OpenAI's image API is a straightforward fit for the job – one endpoint,
one request shape, raster images back. Other providers are welcome as
community contributions (see LLM.md); shinyseo does not bundle a
generator for every LLM vendor, only ones that can actually generate
images and pull their weight as a built-in.
Calling this function does not make any network request – it only builds
and returns the generator. The 'httr' package is required, but only
loaded (via requireNamespace()) when you call this constructor, so
it costs nothing if you never use OpenAI generation.
A function function(prompt, kind) that POSTs to
https://api.openai.com/v1/images/generations and returns the
generated image as a raw vector of bytes.
Call this inside a Shiny server function to update one or more
metadata fields after the page has loaded — for example when the user
navigates between tabs or routes. Only the fields you supply are changed;
all others stay at whatever value social_meta() set at startup.
update_meta( session, title = NULL, description = NULL, url = NULL, image = NULL )update_meta( session, title = NULL, description = NULL, url = NULL, image = NULL )
session |
The Shiny |
title |
New page title. Also updates |
description |
New description. Also updates |
url |
New canonical URL. Also updates |
image |
New share image URL. Also updates |
Called for its side-effect; returns invisible(NULL).
Generates a Web
App Manifest (manifest.json) and writes it to www/ so Shiny
can serve it at /manifest.json. Call this once in global.R
before the app starts.
write_manifest( meta, path = "www", display = "standalone", start_url = "/", background_color = NULL )write_manifest( meta, path = "www", display = "standalone", start_url = "/", background_color = NULL )
meta |
Either a path to a YAML file or a named list. The same object
you pass to |
path |
Directory to write |
display |
Browser display mode. One of |
start_url |
Start URL passed to the manifest. Defaults to |
background_color |
Background colour shown on the splash screen while
the app loads. Defaults to |
Reference manifest.json from the UI by passing
manifest = "/manifest.json" to social_meta().
The path to the written file, invisibly.
Inject social metadata into Shiny UI
Description
Inject social metadata into Shiny UI
Usage
Arguments
metaEither a path to a YAML file or a named list. The final metadata must include
title,description,url, andimage.Details
If
metais a character string, it is treated as a YAML file path and read withyaml::read_yaml(). Setschema = FALSEto suppress JSON-LD output.bing_site_verificationfalls back toSHINYSEO_BING_SITE_VERIFICATIONwhen that environment variable is set.twitter_siteandtwitter_creatorfall back toSHINYSEO_TWITTER_SITEandSHINYSEO_TWITTER_CREATORwhen those environment variables are set. The helper does not emit a<title>tag; set the document title in the app UI so it does not clash with an existing Shiny title. Setapple_mobile_web_app_capable = TRUEto let the app run in standalone mode when added to a phone's home screen (emitsapple-mobile-web-app-capableandmobile-web-app-capable).apple_mobile_web_app_titlesets the name shown under the home screen icon, andapple_mobile_web_app_status_bar_stylecontrols the iOS status bar appearance. Optional verification fields includebing_site_verification,google_site_verification,yandex_site_verification,baidu_site_verification,naver_site_verification,facebook_domain_verification, andpinterest_domain_verification.Value
A
shiny::tags$head()fragment containing canonical, Open Graph, Twitter Card, and optional schema.org metadata.