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

🐛 BUG: head contents placed in body when page has conditional head #2046

Closed
IanVS opened this issue Nov 29, 2021 · 4 comments
Closed

🐛 BUG: head contents placed in body when page has conditional head #2046

IanVS opened this issue Nov 29, 2021 · 4 comments
Assignees
Milestone

Comments

@IanVS
Copy link
Contributor

IanVS commented Nov 29, 2021

What version of astro are you using?

0.21.4

What package manager are you using?

npm

What operating system are you using?

mac

Describe the Bug

I found that my utf-8 encoding was not being applied correctly, and I traced it down to my head contents being placed inside the body instead of in the head. It occurs due to my page looking like this:

{redirect 
  ? <head><meta http-equiv="refresh" content={`0; url=${redirect}`}></head>
  : <Layout>
      It’s a trap!
    </Layout>
}

If I change the redirect to a normal layout or something, it works. So I suppose I just need to make another component to do the redirect. But I wanted to at least let y'all know this is happening.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-v7dk72?file=src/pages/index.astro

IanVS added a commit to DefinedNet/nebula-docs that referenced this issue Nov 29, 2021
@FredKSchott
Copy link
Member

Looks like you got a fix in that commit, but +1 to a larger fix for us. If we can't fix this as a small bug, we're also getting ready to redo our larger head handling soon. RFC here: withastro/roadmap#26

@tony-sull
Copy link
Contributor

An RFC was recently accepted to finalize <head> and <body> behavior 👍

@natemoo-re
Copy link
Member

This is on track to be fixed in withastro/compiler#267 and the subsequent 0.24.x release of astro.

@natemoo-re natemoo-re added this to the 0.24 milestone Mar 9, 2022
@natemoo-re
Copy link
Member

This should be fixed in the newly released [email protected]!

Please give feel free to reopen this issue if you're still having trouble.

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

No branches or pull requests

4 participants