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

fix: comma inclusion in breadcrumb schema #1644

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tyssejc
Copy link

@tyssejc tyssejc commented Dec 5, 2024

What does this PR change? What problem does it solve?
This PR fixes a JSON syntax error in the schema_json.html template that causes Hugo builds to fail. The error occurs in the breadcrumb list generation where commas between JSON objects are not properly handled when adding the self-page item to the breadcrumb list.

The current template attempts to add a comma before the self-page item using this condition:

{{- if (ge (len $bc_list) 2) }}, {{end }}

This causes build failures with error messages like:

ERROR failed to process "/posts/example/index.html": "/var/folders/hugo-transform-error:99:40": expected comma character or an array or object ending on line 99 and column 40"
Error: error building site: render: failed to render pages: failed to process "/authors/luke-skywalker/index.html": "/var/folders/hugo-transform-error:87:40": expected comma character or an array or object ending on line 87 and column 40

The fix simplifies the comma handling logic to:

{{- if $bc_list }}, {{end}}

This ensures proper JSON syntax by adding a comma whenever there are existing breadcrumb items before the self-page addition.

Was the change discussed in an issue or in the Discussions before?
No prior discussion. The issue was discovered when building a site with the theme and verified through testing.

PR Checklist

  • This change adds/updates translations and I have used the template present here.
  • I have enabled maintainer edits for this PR.
  • I have verified that the code works as described/as intended.
  • This change adds a Social Icon which has a permissive license to use it.
  • This change does not include any CDN resources/links.
  • This change does not include any unrelated scripts such as bash and python scripts.
  • This change updates the overridden internal templates from HUGO's repository.

Copy link

sonarqubecloud bot commented Dec 5, 2024

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.

1 participant