How can I add custom scripts in index.html's head part in Docusaurus V2?

我们两清 提交于 2019-12-04 04:04:10

i am also developing a blog which is based on docusaurus.
and it provides the functionality to add script in head tag.
follow below steps :
1. Open siteConfig.js
2. // Add custom scripts here that would be placed in tags.
scripts: ['https://buttons.github.io/buttons.js'],

Instead of React Helmet, use '@docusaurus/Head' instead.

import Head from '@docusaurus/Head';

function Home() {
  const context = useDocusaurusContext();
  const { siteConfig = {} } = context;
  return (
    <Layout>
      <Head>
        <script src="..."></script>
      </Head>
    </Layout>
  );
}

We're working on this feature so you can add this via docusaurus.config.js. You can follow this PR to track the progress: https://github.com/facebook/docusaurus/pull/1831.

We'll release v2.0.0-alpha.27 soon so that you can try it out. Thanks for your patience!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!