-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Unset charset=utf-8 content-type for md/mdx pages #12231
Conversation
🦋 Changeset detectedLatest commit: 6348b48 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is blocked because it contains a major
changeset. A reviewer will merge this at the next release if approved.
I personally think that users should provide the tag themselves. However, Astro is the content framework, so the framework should help users display any type of content, even when it isn't If our head propagation is solid, the I am in favour of |
For markdown or MDX pages without any layout, we actually send the generated HTML as is. So a If the user were to add the Anyways, wanted to clarify a little 😅 I do think there's a good point where Astro is content-focused and it may good to have this automatic behaviour ootb. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bluwy ! Left some comments and a question because I'm not sure whether MDX is going to work exactly the same, or slightly differently. (Since with MDX, there are two different ways to "use a layout" vs only the one way for Markdown pages.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for docs! I still have a tiny bit of work to do on my end to incorporate this on a couple of different pages, but nothing blocking release! 🙌
Changes
charset=utf-8
will no longer be added toContent-Type
in markdown and mdx pages. This matches the behaviour of other pages, e.g. astro or html pages.This PR
This PR adds
<meta charset="utf-8">
automatically to all md/mdx pages if they have no layout. This allows users to type non-ASCII characters without setting up a layout to add the meta tag into the head.Would like your thoughts
A revelation I had (which is very obvious in hindsight) is that you could easily add
<meta charset="utf-8" />
to the.md
or.mdx
pages yourself directly. They accept HTML anyways and you don't really need a layout to put the meta tag in the head to work. So this whole PR felt causing more hidden magic?Do you think it's worth having the behaviour described in the
This PR
section above? Or simply remove it so that users should add the meta tag themselves?Testing
We have existing tests that covers this behaviour.
Docs
withastro/docs#9757
Is somewhat a breaking change which will be documented in the migration guide later. We may also want to add a
charset
note in https://docs.astro.build/en/basics/layouts/#markdown-layouts.