3

I've created a react.js + router v4 project via facebookincubator/create-react-app, and I use Apache 2 without backend language to run my project.

I've read this official doc:

Generating Dynamic Tags on the Server

Since Create React App doesn’t support server rendering, you might be wondering how to make tags dynamic and reflect the current URL. To solve this, we recommend to add placeholders into the HTML, like this:

<!doctype html>
<html lang="en">
  <head>
    <meta property="og:title" content="__OG_TITLE__">
    <meta property="og:description" content="__OG_DESCRIPTION__">

Then, on the server, regardless of the backend you use, you can read index.html into memory and replace OG_TITLE, OG_DESCRIPTION, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML!

If I use apache run my project without any backend language, is there have any way to Generating Dynamic Tags?

Thanks.

2 Answers 2

2

I suggest to use Helmet, it makes easy to manage metas : https://github.com/nfl/react-helmet

Proof of Helmet working with crawlers

https://medium.com/mixed-marketing-technology/our-solution-to-make-seo-work-for-a-react-js-site-rankwatch-blog-9a311b86fb5f

Sign up to request clarification or add additional context in comments.

1 Comment

First: OP wants dynamic tag, not SEO optimization. Second: this is not true, an article from 2016 medium.freecodecamp.org/….
0

With Apache serving up the React app you could solve this problem by jamming server side include statements into the index.html.

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.