2

We're doing a website using StaticSiteGeneratorPlugin, is a website plugin that render the site locally and then we can upload it to S3.

Our code looks basically like this github project

We're using React Helmet to manage our head, meta info and all that, and is working great in the browser, but not when running the prod build.

In the entry.js I have the following. Missing a way to add the generated strings by Helmet into the resulting html, or if there's a better manager than helmet that will work better with the plugin we're using.

export default function render(locals, callback) {
    const element = React.createElement(Root, props);
    const helmet = Helmet.renderStatic();
    const html = ReactDOMServer.renderToString(element);
    callback(null, `<!DOCTYPE html>${html}`);
}

1 Answer 1

1

Try this, but "don't blog about html":

const helmet = Helmet.renderStatic();
var html = ReactDOMServer.renderToString(element);
html.replace("</head>", helmet+"</head>");
callback(null, `<!DOCTYPE html>${html}`);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.