React Helmet在开发中起作用,但不在生产中起作用

时间:2019-02-12 03:05:09

标签: reactjs gatsby react-helmet

我目前在我的GatsbyJS项目中使用react-helmet。我正在尝试为每个页面的标题添加标题。它正在开发中,但在我部署时不起作用。我尝试同时部署到Github Pages和Netlify都没有成功。

Development

Deployment

import React from 'react';
import Layout from '../components/Layout';
import P from '../components/designSystem/P';
import Link from '../components/designSystem/Link';
import H1 from '../components/designSystem/H1';
import Helmet from 'react-helmet';
import { siteInfo } from '../data';

const page = 'About';

export default () => (
  <Layout>
    <Helmet>
      <title>{siteInfo.title + ' | ' + page}</title>
    </Helmet>
    <H1>About Me</H1>
    <P>
      Hi! I'm Adway. I'm currently a sophomore at Saint John's High School in
      Shrewsbury, Massachusetts. 
</P>
  </Layout>
);

1 个答案:

答案 0 :(得分:0)

确保在react-helmet文件中包含gatsby-plugin-react-helmetgatsby-config.js)。

module.exports = {
  plugins: [
    "gatsby-plugin-react-helmet"
    ]
};