Skip to content

fix(layout): add whitespace between html tag attributes - #2773

Merged
cotes2020 merged 3 commits into
cotes2020:masterfrom
kuibinlin:fix/html-attr-whitespace
Jul 15, 2026
Merged

cotes2020 merged 3 commits into
cotes2020:masterfrom
kuibinlin:fix/html-attr-whitespace

Conversation

@kuibinlin

Copy link
Copy Markdown
Contributor

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Description

The <html> element in _layouts/default.html renders its attributes without a separating space, producing invalid HTML:

<html lang="en"data-bs-theme="light">

Running htmlproofer --check-html reports:

Missing whitespace between attributes

(See #2765.)

Root cause

The whitespace-trim markers introduced in 7496dd4 remove all whitespace around the data-bs-theme conditional, including the required separator between the lang and data-bs-theme attributes:

{%- if site.theme_mode == 'light' or site.theme_mode == 'dark' -%}
  data-bs-theme="{{ site.theme_mode }}"
{%- endif -%}

Fix

Trim only the newline before the conditional while emitting an explicit space before data-bs-theme:

- {%- if site.theme_mode == 'light' or site.theme_mode == 'dark' -%}
-   data-bs-theme="{{ site.theme_mode }}"
- {%- endif -%}
+ {%- if site.theme_mode == 'light' or site.theme_mode == 'dark' %} data-bs-theme="{{ site.theme_mode }}"{% endif -%}

The generated output is now valid:

<html 
  lang="en" data-bs-theme="light">

When theme_mode is unset (the default/auto mode), the data-bs-theme attribute is still omitted:

<html lang="en">

There is no behavioral change—this fix only restores the required whitespace between attributes when a theme mode is configured.

Testing

Built the site with:

JEKYLL_ENV=production

Verified that the generated <html> tag contains valid whitespace between the lang and data-bs-theme attributes.

Additional context

Fixes #2765.

@cotes2020 cotes2020 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the original code indentation?

@kuibinlin

Copy link
Copy Markdown
Contributor Author

Why change the original code indentation?

The indentation was just my preference. It wasn't needed. I have changed it back to the original formatting.

Comment thread _layouts/default.html Outdated
Co-authored-by: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Signed-off-by: Kuibin Lin <69464353+kuibinlin@users.noreply.github.com>
@kuibinlin
kuibinlin force-pushed the fix/html-attr-whitespace branch from ea63397 to fe1745c Compare July 15, 2026 03:15
@cotes2020
cotes2020 merged commit ae677a8 into cotes2020:master Jul 15, 2026
4 checks passed
eshaanraval pushed a commit to eshaanraval/novismos that referenced this pull request Sep 16, 2026
eshaanraval pushed a commit to eshaanraval/novismos that referenced this pull request Sep 16, 2026
eshaanraval pushed a commit to eshaanraval/novismos that referenced this pull request Sep 16, 2026
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

Successfully merging this pull request may close these issues.

Commit 7496dd4 breaks HTML validation

2 participants