-
-
Notifications
You must be signed in to change notification settings - Fork 8.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
Comments can end up displaying inside description meta #6108
Comments
Can reproduce and confirmed it's not an MDX problem 👍 Will look into this |
Haha, @jmynes I know what's wrong.
|
Hey, I'm sorry but I don't really understand this issue, it seems a bit messy to me. Please be aware that the meta description that we infer from your content is only a best-effort, and it's preferable to use an explicit description. You can do that in 2 ways:
<head>
<meta name="description" content="This description will work correctly" />
<meta property="og:description" content="This description will work correctly" />
</head> @Josh-Cena this isn't really worth it to invest fixing the default, we should mostly recommend to always use a |
No, the problem is:
My proposal is that we get rid of the makeshift |
Patching the description generation is easy: just try to ignore multi-line comments like we do for fenced code blocks, like a state machine. The problem is, where do we end? |
But yes, @jmynes I failed to mention that you can set a front matter instead of using the |
That wouldn't really allow being more compatible with CommonMark. In the end, using content as SEO description can't work in all situations. Even if we have the perfect code to skip comments, ultimately the first sentence may not be a good text for this use-case. We could as well totally disable this fallback and always ask users for an explicit description. Not handling comments correctly can be considered as a bug, but it's a low priority one considering using description inference is not the best idea in the first place and we should encourage to use an explicit description. Still, if you find a way to improve the inference, why not, but for me the workarounds are good enough |
It's not about CM compatibility. It's about ridding the pain to support a custom Markdown parser that falls apart on many edge cases. I agree with two things:
However, we can easily refactor this into a remark plugin. I would probably raise a POC later |
Agree that reading things from content with Regexp is not the best. A remark plugin can be nice to extract that description (and blog excerpts probably too). In which case it's probably a nice idea to ensure that we don't parse the whole doc as AST and the visitor can bail-out asap, for perf reasons. I don't know if this remark plugin could run as part of mdx-loader (it means description wouldn't be part anymore of doc metadatas) |
Mmm, we can certainly use Remark outside of MDX. But we'll see if we run into any trouble with the lack of description as metadata |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
Issue: My .md or .mdx files are loading comments into the content of the meta property
og:description
<meta property="og:description" content="<!-- This comment WILL NOT be ignored:" data-react-helmet="true">
Steps to reproduce
Example code structure to replicate this issue:
Expected behavior
og:description should not be pulling comments in to fill its content
Actual behavior
og:description seems to pull the first text after even if it's a comment?
No log messages output.
Your environment
I have already fixed this issue in prod on our site's affected page, https://docs.domination.finance/liquidity_providers, by manually overriding the meta tag for og:description
Reproducible demo
No response
Self-service
The text was updated successfully, but these errors were encountered: