zhaohuabing / hugo-theme-cleanwhite

A clean, elegant blog theme for hugo
Apache License 2.0
730 stars 340 forks source link

Invalid Twitter card type #140

Closed lcx closed 2 years ago

lcx commented 2 years ago

If a summary is present in the yaml frontmatter, the theme will use that as the twitter:card value.

https://github.com/zhaohuabing/hugo-theme-cleanwhite/blob/master/layouts/partials/head.html#L39

but there are only a few valid values: https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started

The card type, which will be one of “summary”, “summary_large_image”, “app”, or “player”.

So if you don't have a summary, it will actually work. I'm not sure if this should be hardcoded as summary or probably allow it to be configured via yaml frontmatter? I'm pretty new to hugo and hugo go themes, but this is what I could come up with:

A post could contain this:

---
summary: some summary text here
twitter:
  card: "summary_large_image"
draft: false
---

then in layouts/partials/head.html

    {{ if .Params.twitter.card }}
    <meta property="twitter:card" content="{{ .Params.twitter.card }}" />
    {{ else }}
    <meta property="twitter:card" content="summary" />
    {{ end }}
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.