New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Open Graph meta tags #438

Merged
merged 10 commits into from Feb 20, 2018

Conversation

Projects
None yet
2 participants
@nealrichardson
Contributor

nealrichardson commented Oct 31, 2017

The Open Graph protocol and Twitter Card properties provide standards for website/page metadata. One important application of them is in providing previews when sharing links, whether on social media or on services like Slack.

This PR implements some of these meta tags, enough to give a preview of a pkgdown site link like this (on Slack):

screen shot 2017-10-30 at 7 21 04 pm

Specifically, it:

  • adds og:title, og:description, og:image, and twitter:card meta tags to the head.html template;
  • identifies suitable "description" metadata for the package index.html (the "Description" from DESCRIPTION), the reference pages (the function "description"), and the articles/vignettes (if specified in the YAML front matter), and makes it available to the template;
  • ensures that, if a logo.png is present in the package, it is included in the built site, and uses it as the preview image;
  • adds a single test that the template is rendered with the og:description

It's getting the job done for me on sites I've built with it, but it is not what I would consider a complete implementation. It needs documentation, more tests, and it's worth considering what an appropriate "description" should be for some of the other pages (reference index, news, etc.). But before I proceeded with that, I wanted to put this out there, gauge interest, and get design feedback.

@hadley

One small style problem, otherwise looks good!

Show outdated Hide outdated R/build-home.R Outdated
@nealrichardson

This comment has been minimized.

Show comment
Hide comment
@nealrichardson

nealrichardson Nov 6, 2017

Contributor

Fixed a few =s and added some tests that the templates were being rendered with the right metadata. Incidentally, this increases the package's test (line) coverage from 63% to 78%.

Contributor

nealrichardson commented Nov 6, 2017

Fixed a few =s and added some tests that the templates were being rendered with the right metadata. Incidentally, this increases the package's test (line) coverage from 63% to 78%.

@hadley hadley merged commit f8df34c into r-lib:master Feb 20, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@hadley

This comment has been minimized.

Show comment
Hide comment
@hadley

hadley Feb 20, 2018

Member

Thanks!

Member

hadley commented Feb 20, 2018

Thanks!

@nealrichardson nealrichardson deleted the nealrichardson:open-graph branch Apr 5, 2018

@maelle maelle referenced this pull request Oct 11, 2018

Open

Add OpenGraph metatags #104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment