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 page descriptions to meta description tag #60

Open
joeroe opened this issue Sep 1, 2023 · 1 comment
Open

Add page descriptions to meta description tag #60

joeroe opened this issue Sep 1, 2023 · 1 comment

Comments

@joeroe
Copy link
Owner

joeroe commented Sep 1, 2023

Although a bit off-topic, I think you should also add page description to single page template instead of a site level description?

{{ with .Site.Params.about }}<meta name="description" content="{{ .description }}">{{ end }}

Maybe something like this, I'm not sure whether the page description would just override the site one.

<!-- Site level -->
{{ with .Site.Params.about }}<meta name="description" content="{{ .description }}">{{ end }}
<!-- Page level -->
<meta name="description" content="{{ .Params.description }}">

Originally posted by @Vinfall in #55 (comment)

@joeroe joeroe changed the title Add page description to default single page template Add page descriptions to meta description tag Sep 1, 2023
@TheGroundZero
Copy link

Looks like you could kill two birds with one stone by using Param, see https://gohugo.io/methods/page/param/

Returns a page parameter with the given key, falling back to a site parameter if present.

{{ with .Param.description }}<meta name="description" content="{{ . }}" />{{ end }}

But then either the site description would have to be moved from params.about to params or the page description would have to be moved to about.description.

Or you do something like:

<meta name="description" content="{{ with .Params.description -}}{{ . }}{{- else -}}{{ .Site.Params.About.description }}"{{ end }}/>

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

No branches or pull requests

2 participants