#Prevent adding closing slash to an *empty* tag

3 messages · Page 1 of 1 (latest)

true cape
#

When building styles, Astro generates a <link rel="stylesheet" href="/path/to/hashed.css" /> tag with a closing slash. How can I prevent it from adding this slash to an empty tag?

livid gorgeBOT
#

Hi @true cape. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the provided knowledge sources, there isn't a direct way to prevent Astro from adding a closing slash to an empty tag. However, there was a similar issue reported on Github where empty elements set in customData were converted to use closing tags. The proposed solution was to include suppressEmptyNode: true in the xmlOptions used with XMLParser and XMLBuilder. This might not directly apply to your case, but it could be a starting point for further investigation.

Here is the relevant extract from the knowledge source:

Empty elements set in `customData` are converted to use closing tag.
Ex:
`customData: &amp;#x27;&amp;lt;atom:link href=&amp;quot;${import.meta.env.SITE}rss.xml&amp;quot; rel=&amp;quot;self&amp;quot; type=&amp;quot;application/rss+xml&amp;quot; /&amp;gt;&amp;#x27;`
becomes:
`&amp;lt;atom:link href=&amp;quot;<https://domain.com/rss.xml&amp;quot;> rel=&amp;quot;self&amp;quot; type=&amp;quot;application/rss+xml&amp;quot;&amp;gt;&amp;lt;/atom:link&amp;gt;`
**Possible solution**
Including `suppressEmptyNode: true` in the `xmlOptions` used with `XMLParser` and `XMLBuilder` fixes this. Any downsides?

(Source: Github Issue (closed): [astro-rss] Forced closing tags in customData > Original post (https://github.com/withastro/astro/issues/5794))

Please note that this solution was proposed in the context of a specific issue and might not apply directly to your case. It's recommended to check the official Astro documentation or reach out to the Astro community for more specific guidance.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: