Skip to content

head extension mishandles title #4070

Description

@scrhartley

The trouble with the title tag appears when using the extension with hx-head="append".
The title is something that intrinsically changes between pages and so when using append it will cause multiple titles to appear.
The problem affects the extension for both htmx v2 and v4.

For my local workaround, I disable title handing entirely, since htmx already handles titles itself and so there's an argument that it's not the extension's responsibility to manage them at all.

Here is a simple reproduction with two pages using boosting. Toggling between the two results in multiple title elements.
Page 1

<!DOCTYPE html>
<html>
  <head hx-head="append">
    <script src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0/dist/htmx.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0/dist/ext/hx-head.js"></script>
    <title>Page 1</title>
  </head>
  <body hx-boost:inherited="true">
    <a href="page2.html">Page 2</a>
  </body>
</html>

Page 2

<!DOCTYPE html>
<html>
  <head hx-head="append">
    <script src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0/dist/htmx.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0/dist/ext/hx-head.js"></script>
    <title>Page 2</title>
  </head>
  <body hx-boost:inherited="true">
    <a href="page1.html">Page 1</a>
  </body>
</html>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions