をあなたからあなたのリアクトバンドルを提供している場合サーバー上にメタタグを動的に生成することができます。
基本的に、index.htmlをあなたが識別できる文字列でメタデータを交換したいファイル/公開中:
<!-- in public/index.html -->
<title>$OG_TITLE</title>
<meta name="description" content="$OG_DESCRIPTION" />
<meta property="og:title" content="$OG_TITLE" />
<meta property="og:description" content="$OG_DESCRIPTION" />
<meta property="og:image" content="$OG_IMAGE" />
し、サーバー上の、あなたは、動的に生成された情報とこれらの文字列を置換します。
app.get('/about', function(request, response) {
console.log('About page visited!');
const filePath = path.resolve(__dirname, './build', 'index.html')
fs.readFile(filePath, 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
data = data.replace(/\$OG_TITLE/g, 'About Page');
data = data.replace(/\$OG_DESCRIPTION/g, "About page description");
result = data.replace(/\$OG_IMAGE/g, 'https://i.imgur.com/V7irMl8.png');
response.send(result);
});
});
ここで、このチュートリアルから撮影:https://www.kapwing.com/blog/how-to-add-dynamic-meta-tags-server-side-with-create-react-app/
ここでノードとExpressでの例のルートがあります