Thanks to visit codestin.com
Credit goes to github.com

Skip to content

proposal: Preserve intentional empty maps in hugo config output #14944

@jmooring

Description

@jmooring

PR #14934 drops empty sub-maps from hugo config output to reduce noise. However, this also removes contentTypes, whose entries are intentionally empty — they have no per-type options, so ContentTypeConfig is an empty struct by design.

Proposed fix: in removeZeroVAlues, distinguish between maps that are originally empty (intentional, preserve them) and maps that became empty after their zero-valued entries were stripped (noise, remove them). The #14934 behavior is otherwise unchanged.

With this fix, hugo config output includes the contentTypes section regardless of output format, restoring the behavior from v0.161.1. Users who discovered the --printZero workaround would no longer need it for this section.

For example, this command:

hugo config --format toml | grep -i contentTypes

Should produce this output:

[contenttypes]
  [contenttypes.'text/asciidoc']
  [contenttypes.'text/html']
  [contenttypes.'text/markdown']
  [contenttypes.'text/org']
  [contenttypes.'text/pandoc']
  [contenttypes.'text/rst']

Without this functionality it is difficult to determine which are enabled/disabled.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions