Skip to content
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 meta og tags #39

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

monkeywithacupcake
Copy link

@monkeywithacupcake monkeywithacupcake commented Apr 3, 2021

changes all templates in Pandoc (html) and skeleton (rmd) to allow for automatic meta/og tags without installing another package.

closes #32

relies on the already included title and image information.

Using this in the yaml:

meta:
  description: "data.coffee.run"
  url: "https://monkeywithacupcake.github.io"
  twitter: "jessachandler"

**results in this in the html header: **

 <meta name="description" content="data.coffee.run" />
      <meta name="twitter:description" content="data.coffee.run" />
      <meta name="og:description" content="data.coffee.run" />
      <meta name="twitter:title" content="Cheers!" />
      <meta name="og:title" content="Cheers!" />
      <meta name="twitter:url" content="https://monkeywithacupcake.github.io" />
      <meta property="og:url" content="https://monkeywithacupcake.github.io" />
      <meta name="twitter:image:src" content="https://monkeywithacupcake.github.io/jess.jpg" />
      <meta property="og:image" content="https://monkeywithacupcake.github.io/jess.jpg" />
      <meta name="twitter:card" content="summary" />
      <meta name="twitter:creator" content="@jessachandler" />
      <meta name="twitter:site" content="@jessachandler" />

and this twitter card:

Screen Shot of twitter card validator

adds meta section to support social sharing if meta vars found.
three new variables used: meta.description, meta.url, and meta.twitter
reuses variables: title, image
adds meta section to support social sharing if meta vars found.
three new variables used: meta.description, meta.url, and meta.twitter
reuses variables: title, image
adds meta section to support social sharing if meta vars found.
three new variables used: meta.description, meta.url, and meta.twitter
reuses variables: title, image
adds meta section to support social sharing if meta vars found.
three new variables used: meta.description, meta.url, and meta.twitter
reuses variables: title, image
add meta to yaml
add meta to yaml
add meta to yaml
add meta to yaml
remove dashes
remove dashes
remove dashes
remove dashes
add quotes around variables in meta tags
add twitter at
deal with literal at
deal with literal at
deal with literal at
removes self close meta
add closing meta tags
add url to image meta
fixes meta tags and adds url to image
close jolla meta tags and add url image
close meta tags and add image url
explains the meta options in readme
@monkeywithacupcake monkeywithacupcake changed the title Add meta og Closes #32 Add meta og tags Apr 3, 2021
@hadley
Copy link
Contributor

hadley commented Jan 2, 2022

This would be a good place to try a template partial: https://pandoc.org/MANUAL.html#partials

README.md Outdated Show resolved Hide resolved
<meta name="twitter:url" content="$meta.url$"></meta>
<meta property="og:url" content="$meta.url$"></meta>
<meta name="twitter:image:src" content="$meta.url$/$image$"></meta>
<meta property="og:image" content="$meta.url$/$image$"></meta>
Copy link

@gadenbuie gadenbuie Jan 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to og:image, I recommend that postcards also support the og:image:alt and twitter:image:alt tags as well. One option would be to add image_alt or meta.image_alt (or both) to the YAML:

meta:
  description: "floatplane data artist"
  url: "example.com"
  twitter: "yourname"
  image: https://example.com/social.png
  image_alt: Short description of social card image.
image: avatar.png
image_alt: Short description of avatar image.

The two tags to add would be something like

<meta name="twitter:image:alt" content="$if(meta.image_alt)$$meta.image_alt$$else$$image_alt$$endif$"/>
<meta property="og:image:alt" content="$if(meta.image_alt)$$meta.image_alt$$else$$image_alt$$endif$"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relatedly, image_alt could be added here

<img src="$image$" style="height:15rem" class="rounded float-right">

monkeywithacupcake and others added 6 commits March 12, 2022 10:19
removes alternative for editing resulting file 
responding to code review
makes twitter creator conditional on twitter
makes twitter conditional
incorporates alternative urls

Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>
adds twitter conditional
adds twitter conditional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for twitter cards
3 participants