Enable line breaks in titles#57
Merged
DanilaFe merged 2 commits intochapel-lang:mainfrom Feb 24, 2026
Merged
Conversation
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
benharsh
approved these changes
Feb 23, 2026
Member
|
The result looks good to me, Daniel, and I appreciate the rationale for the approach taken! |
bradcray
added a commit
that referenced
this pull request
Feb 25, 2026
Leveraging Daniel's #57, this uses the new 'richtitle' field to force linebreaks for more titles. Some of these are arguably silly / inconsequential (splitting a line before a preposition rather than after), but some feel good to me (e.g., the HPCwire interview). The 10 myths articles are one of the most awkward cases... I removed the comma from the rich title because it caused "(Redux)" to start the second line in the summary view, which felt a bit unfortunate; however, in the full-article view, it is now on a line of its own rather than the original line. I still think I prefer this since the "part n: " part of the title gets a line of its own, which feels more important to me. --- Signed-off-by: Brad Chamberlain <bradcray@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #54.
This PR enables adding line breaks in post titles. These line breaks occur when the title is rendered on the page itself, as well when the title is rendered in the posts list. See examples below.
My approach has been to add a new title property (
richtitle) to the posts' front matter. The reason I did so is because of the surprising number of ways in which titles were used in a non-visual context. This included:alt=properties forimgtags (author pages)<br>is specifically what's needed in post titles for line breaks. This is because "rendering" titles is handled like rendering markdown, where a single\nis insignificant and\n\nindicates a paragraph break, which for titles would imply an invalid<h><p></p><p></p></h>structure. The<br>element is specifically a line-break hint without a "new paragraph" implication. However, including<br>in title tags verbatim (as it is in the newrichtitlefield) means that anywhere where the string isn't rendered to HTML (sample list above), we must strip the HTML tags instead. But Hugo's stripping replaces<br>s with newlines, which also aren't always appropriate. In the end, applying this change broadly causes a big HTML diff and is dubiously correct. This, combined with the fact that Hugo uses.Titlefor many things by default (and possibly even more things in the future), made me switch to a separate field in which markup is expected.This led me to the
richtitlefield, and a design in which places where newlines in titles can work should explicitly check therichtitlefield. To save the boilerplate of "use rich title if present, or regular title if not", I defined therichtitle.htmlpartial.I glanced the diff and as far as I can tell, nothing besides
<br>s-in-titles has changed. An LLM (Claude) shares this opinion, and didn't flag anything concerning.Reviewed by @benharsh -- thanks!
Results
Before:

After:

I've added newlines to all the posts in the "7 questions" series.