Twitter card template doesn't get aligned with the rest of the template

Hello, I enabled the twitter cards template and it shows up in the HTML source code but notice that only the first line <meta name="twitter:card" ....> is indented two spaces the others are not.

Is there a way to make those last three lines indent two space as well?

This is how it looks in the theme:

<head>
  <meta charset="UTF-8">
  {{ hugo.Generator }}
  <meta name="author" content="{{ .Site.Params.author }}">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="{{ with .Page.Description }}{{ . }}{{ else }}{{ .Site.Params.description }}{{ end }}">
  {{ template "_internal/twitter_cards.html" . }}

You could modify the internal twitter template with your own: hugo/twitter_cards.html at master · gohugoio/hugo · GitHub

… though I don’t personally understand why it would even be an issue? This appears in your <head> tags, and whitespace here would have no effect on your published page.

2 Likes

Do you mean by creating a partial and then importing it with something like {{ partial "twitter-card.html" . }} and just copy and paste the code you linked from git?

Yep.

Note that you will have to keep it up to date yourself should the internal template be updated in the future.

1 Like