我有一个问题,在我的项目中,我不能使用 * SSR, Helm * 和 * 后端 , 是可能的,我们可以使用动态Meta而不使用SSR和后端 ,如果我们可以只使用react js在前端,和 * 我已经尝试react helment,但它是不工作在我的项目 ,因为我的项目是非常大的,所以如果eny解决方案请给予我答案...
我已经尝试了许多解决方案和React库,但没有任何一个工作像... * Helm ,react-heam,react-heam-async,react-meta-tags,react-meta
2条答案
按热度按时间hgncfbus1#
我使用下面的程序实现了这一点,它对我很有效,
在react js public/index.html中编写PHP代码,仅基于文件顶部的url slug获取Meta标签
字符串
然后创建.htaccess文件,其中index.html福尔斯在服务器中,并在.htacess中编写下面的代码
型
然后按如下方式更新package.json
型
现在它会成功的
t2a7ltrp2#
我不确定你想达到什么目的。这个概念分为两种选择。服务器端或客户端。
如果是客户端,你应该对 react-helmet 感到满意。你说你的项目很大。我不认为这与项目大小有关,可以动态地更改Meta。我认为为什么你不能完成react-helmet是因为你没有从你的index.html中删除静态 Meta 代码。发生的事情是,你可能会得到客户端动态Meta,它是从 Helm 生成的,但被来自index.html的静态元标记所取代。所以把它们取下来应该会很好...
现在来动态 SEO 为OG(开放图)Meta标签没有SSR。有一些预渲染动态Meta标签的包可能有助于解决您的问题,而无需在您的 React App 上实现SSR。