
Generate and embed the schema.org metadata of the data package
Source:R/update_metadata.R
update_metadata.Rdupdate_metadata() derives a schema.org Dataset description from the
canonical sources of the package and writes it as a JSON-LD block into the
head of every pkgdown page, where dataset search engines read it. Nothing
is hand edited: to change a value, change its source and run the function
again. Running it twice produces no change. It ends by listing the fields
it could not fill and where to fill them.
The sources are:
| Field | Source |
| name, description, version, datePublished, license | Title, Description, Version, Date, License in DESCRIPTION |
| url | the pkgdown site (a github.io entry in URL), else the repository |
| keywords | X-schema.org-keywords in DESCRIPTION, comma separated |
| spatialCoverage, temporalCoverage | X-schema.org-spatialCoverage and X-schema.org-temporalCoverage in DESCRIPTION |
| isBasedOn | the source article DOIs in X-schema.org-isBasedOn in DESCRIPTION, comma separated |
| creator, maintainer, funder, publisher | Authors@R roles aut/cre, cre, fnd, cph; ORCID from the comment field, and the ROR comment key of an organisation as its @id. Without a cph, the publisher is the organisation with the website in Config/washr/home. The organisations in Config/washr/parent-organizations nest under the publisher as parentOrganization, a https://ror.org/ URL as the @id; the entries up to and including the publisher itself (same name, or the publisher name followed by a comma) are skipped |
| includedInDataCatalog | the data catalogue of the organisation in Config/washr/catalog |
| identifier, sameAs | the DOI in CITATION.cff, written by update_citation() |
| variableMeasured | data-raw/dictionary.csv |
| distribution | every file in inst/extdata that belongs to a dataset, one entry per file |
The JSON-LD lands in pkgdown/templates/in-header.html, which pkgdown
picks up on the next site build. The file also keeps the in_header
includes from _pkgdown.yml working. The same JSON-LD is also written to
pkgdown/assets/metadata.jsonld, which pkgdown copies to the root of the
site, so the metadata has its own address (<site>/metadata.jsonld) for
tools that read files rather than page heads; the README links it. Each
file is written only when its content changed. Neither is shipped in the
package tarball.
Value
The Dataset description as a list, invisibly. The "blank"
attribute names the fields that could not be filled and says where to
fill them.
See also
Before: update_description(), which writes the DESCRIPTION fields this reads. Next: setup_readme(). The DOI comes from update_citation().
Other metadata functions:
update_citation(),
update_description(),
update_zenodo_json()