You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.4 KiB

4 years ago
  1. +++
  2. title = "Social Meta"
  3. description = "Share links with images on Facebook and Twitter."
  4. categories = ["social"]
  5. tags = ["author", "metadata", "images"]
  6. features = ["code highlighter", "snippets", "related content"]
  7. [[copyright]]
  8. owner = "Josh Habdas"
  9. date = "2019"
  10. license = "agpl-3.0-or-later"
  11. +++
  12. After Dark provides {{< external text="Open Graph Protocol" href="http://opengraphprotocol.org" />}} and {{< external href="https://developer.twitter.com/en/docs/tweets/optimize-with-cards" text="Twitter Cards" />}} metadata in pages to achieve rich sharing cards on WhatsApp, Twitter, Telegram and more:
  13. ![Open Graph sharing card screenshot](/images/instant-view-fs8.png "Example Open Graph sharing card produced by After Dark")
  14. Adjust `author` in {{< external href="https://gohugo.io/getting-started/configuration/" text="Site Configuration" />}} to specify name shown, if any:
  15. ```toml
  16. [params]
  17. author = "Bali Bebas!"
  18. ```
  19. Set or override `author` per page using{{< external href="https://gohugo.io/content-management/front-matter/" text="Front Matter" />}} as shown here:
  20. ```toml
  21. title = "Become a Digital Nomad in Bali: The Lost Guide"
  22. description = "Everything you need to know to become a Digital Nomad in Bali."
  23. author = "After Dark"
  24. date = "2017-02-02T11:57:24+08:00"
  25. publishdate = "2017-01-28T02:31:22+08:00"
  26. images = [
  27. "https://source.unsplash.com/-09QE4q0ezw/2000x1322"
  28. ]
  29. ```
  30. Adjust `images` to specify an external image or, if using {{< external href="https://gohugo.io/content-management/page-bundles/" text="Page Bundles" />}}, specify the relative path to the image resource to use:
  31. ```toml
  32. images = [
  33. "/post/post-title/images/lana-abie-581813-unsplash.jpg"
  34. ]
  35. ```
  36. {{% hackcss-alert type="info" %}}**Why use arrays?** Open Graph supports multiple image sizes. And though After Dark doesn't support multiple sizes, users can create [custom layouts](../custom-layouts) that do.{{% /hackcss-alert %}}
  37. If no page-level image is provided After Dark will fallback to a site-wide image which may be adjusted or removed from {{< external href="https://gohugo.io/getting-started/configuration/" text="Site Configuration" />}}:
  38. ```toml
  39. [params]
  40. images = [
  41. "https://source.unsplash.com/-09QE4q0ezw/2000x1322" # site-wide og:image
  42. ]
  43. ```
  44. See {{< external href="https://unsplash.com/" text="Unsplash" />}} and {{< external href="https://source.unsplash.com/" text="Unsplash Source" />}} for thousands of royalty-free images.