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

onRenderBody and onPreRenderHTML are not being called in gatsby-ssr #28170

Closed
ilyador opened this issue Nov 19, 2020 · 4 comments
Closed

onRenderBody and onPreRenderHTML are not being called in gatsby-ssr #28170

ilyador opened this issue Nov 19, 2020 · 4 comments
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@ilyador
Copy link

ilyador commented Nov 19, 2020

This is how my gatsby-ssr looks like:

import React from 'react'
import Helmet from 'react-helmet'
import Wrapper from './src/templates/pages-layout'

export const wrapRootElement = ({ element }) => <Wrapper>{element}</Wrapper>

export const onRenderBody = ({ setHeadComponents, setHtmlAttributes, setBodyAttributes }) => {
...
}

export const onPreRenderHTML = ({ getHeadComponents, replaceHeadComponents }) => {
...
}

Whatever I put inside onRenderBody and onPreRenderHTML is never executed, even the simplest things to test like console.log.

For context, I am trying to implement this solution to the SEO issue #22206 (comment)

@ilyador ilyador added the type: bug An issue or pull request relating to a bug in Gatsby label Nov 19, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Nov 19, 2020
@ilyador ilyador changed the title onRenderBody and onPreRenderHTML are not being called at all on gatsby-ssr onRenderBody and onPreRenderHTML are not being called in gatsby-ssr Nov 19, 2020
@ascorbic
Copy link
Contributor

Hi @ilyador

I've tried reproducing this with similar code to yours, and have had no luck. To help us best begin debugging the underlying cause, it would be really helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.

Thanks!

@ascorbic ascorbic added status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Nov 19, 2020
@ediblecode
Copy link
Contributor

I was trying to do something similar the other day with onPreRenderHTML. It may seem obvious...but that doesn't work in develop mode, only when doing a production build, so double check which mode you're. It took me a while to realise/remember that develop renders client side, so won't call onPreRenderHTML. That changes with #27432 though!

@Darth-Knoppix
Copy link

Perfect timing, I ran into this today but 2.27.0 is out 👍

@LekoArts
Copy link
Contributor

Hi!

Since we didn't receive an answer for 7 business days or more about the ask of a reproduction I'm going to close this now, as we can't do much to help without a reproduction. If you are able to create a minimal reproduction for this then please do answer here or reopen the issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

5 participants