Skip to content

[Bug]: Cannot use separate front matter description and summary for meta description #2925

@aplgr

Description

@aplgr

Issue Check

  • I have checked existing Issues and I feel this bug has not been raised

Hugo Version Check

  • My Hugo version is within the supported range

Describe the Bug

The current meta description fallback order prefers .Params.Summary over .Params.Description:

{{ with (.Params.Summary | default .Params.Description) | default .Site.Params.description }}
  <meta name="description" content="{{ . }}">
{{ end }}

This means that an explicitly configured description in a page's front matter is ignored whenever summary is present.

According to the Blowfish front matter documentation, description is intended for HTML metadata, while summary is intended as the article summary when summaries are shown.

Because of that, I would expect Blowfish to provide a built-in way to use description as the primary source for the HTML meta description.

I understand that changing the default fallback order could affect existing sites. However, at the moment there does not seem to be a way to use separate article summaries and SEO/meta descriptions without overriding the entire head.html partial.

To Reproduce

Create an article with both summary and description in the front matter:

---
title: "Example Article"
summary: "Short teaser text shown in article lists."
description: "SEO-oriented meta description for search engines and social previews."
---

Build the site and inspect the generated HTML head.

The generated meta description uses summary:

<meta name="description" content="Short teaser text shown in article lists.">

Expected Behaviour

There should be a supported way to make the generated meta description use description when it is explicitly set:

<meta name="description" content="SEO-oriented meta description for search engines and social previews.">

To avoid breaking existing sites, the current fallback order could remain the default. Users who want separate article summaries and SEO/meta descriptions could opt into a different order through site configuration.

Suggested fix

A backwards-compatible fix could be to make the meta description fallback order configurable.

The current behavior could remain the default:

[params.seo]
metaDescriptionOrder = ["summary", "description", "site"]

Users who want the documented description field to take precedence could opt in:

[params.seo]
metaDescriptionOrder = ["description", "summary", "site"]

The template could then resolve the first available value from that configured order.

For example:

{{ $metaDescriptionOrder := .Site.Params.seo.metaDescriptionOrder | default (slice "summary" "description" "site") }}
{{ $metaDescriptionSources := dict
  "summary" .Params.Summary
  "description" .Params.Description
  "site" .Site.Params.description
}}
{{ $metaDescription := "" }}

{{ range $metaDescriptionOrder }}
  {{ $metaDescription = $metaDescription | default (index $metaDescriptionSources (lower .)) }}
{{ end }}

{{ with $metaDescription }}
  <meta name="description" content="{{ . | plainify }}">
{{ end }}

This would avoid breaking existing sites while making it possible to use separate article summaries and SEO/meta descriptions without overriding the full head.html partial.

Using plainify would also avoid raw Markdown being emitted into the meta description when the fallback value comes from summary.

Screenshots

No response

Platform

  • OS: Linux
  • Browser: firefox
  • Version: 150

Hugo Version

hugo v0.160.1+extended+withdeploy linux/amd64

Blowfish Version

v2.102.0

Additional Context

This is related to #690, where the current behavior and the backwards compatibility concern were discussed before.

The suggestion above keeps the current behavior as the default, but adds an opt-in path for users who want description to take precedence over summary.

This would solve the issue without forcing existing sites to change their generated meta descriptions.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions