Skip to content

Instantly share code, notes, and snippets.

@AeonFr
Created May 23, 2018 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AeonFr/3144f586716638fd75caf77f3c75111f to your computer and use it in GitHub Desktop.
Save AeonFr/3144f586716638fd75caf77f3c75111f to your computer and use it in GitHub Desktop.
<!-- facebook open graph & google tags (this also works for twitter) -->
<!-- This are usefull mostly for machines. -->
<meta property="og:url" content="https:{{ .Permalink }}" />
<!-- es_AR means "spanish from Argentina". Not really supported, though. That's why there's a fallback -->
<meta property="og:locale" content="es_AR" />
<meta property="og:locale:alternate" content="es_LA" />
<!-- This properties are the more important: they determine how the card looks in Fb, Tw, linkedin & slack -->
<meta property="og:title" content="{{ .Title }}" />
<meta name="description" content="{{ .Description }}">
<meta property="og:description" content="{{ .Description }}" />
<!-- CHOOSE ONE - http://ogp.me/#types -->
<meta property="og:type" content="website" />
<meta property="og:type" content="product" />
<meta property="og:type" content="article" />
<!-- RECOMENDED IMAGE SIZE: 1200x630px -->
<meta property="og:image" content="">
<!-- THIS IS OPTIONAL BUT RECOMMENDED -->
<meta propery="og:image:width" content="1200">
<meta propery="og:image:height" content="630">
@AeonFr
Copy link
Author

AeonFr commented May 24, 2018

In PHP, it's easy to print the og:url by using:

<?= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>

If you have multiple domains pointing to one website, you could even hardcode the domain name.

<?= 'http://www.mydomain.com' . $_SERVER['REQUEST_URI']; ?>

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