雨果与反应?
Hugo with React?
是否possible/ideal 将 Hugo 之类的东西与 React 一起使用?我知道盖茨比,但雨果也会工作吗?我对将两者结合起来了解有限,但我的理解是 Hugo 将用于所有模板和静态网页,然后 React 将用于 Web 应用程序类型的事物,以及那里某处的无头 CMS?有经验的人可以评论为什么 Hugo 或 Gatsby 有时很适合与 React 一起使用吗?或者框架之间关系的概述?
是的,
gatsby中有组件网页设计,
还有hugo的光速,
我也在纠结于这两者之间。
我不知道我会做什么,但我的想法是:
- 使用gatsby构建页面。您应该自己构建网站的每个页面(不要依赖路由)
- 使用带有 hugo 模板的
index.html
文件。
- 完成
这是构建 gatsby 页面后文件夹 public
的图片(输出):
更新:
你可以依赖路由。在上图中,每个组件文件夹都有自己的 index.html
,因此您也可以使用它们。
2021 年更新:
使用Next.JS。使用 Incremental Static Regeneration
功能,您甚至可以在不接触 Hugo 的情况下实现您想要的。
Is it possible/ideal to use something like Hugo with React? I am aware
of Gatsby, but would Hugo work as well.
我们在 https://www.electrade.app 将 Hugo 与 React (create-react-app) 结合使用。所有页面都用于 hugo 静态页面,但如果你导航到 /quote,react SPA 加载并且你处于动态状态。所以是的,Hugo 也可以工作,但是你将拥有 2 种语言和 2 种语法。
combining the two [...] my understanding would be that Hugo would be
used for all your templating and static web pages and then React would
be used for the web application type of things
完全正确。
Can someone with experience comment why Hugo or
Gatsby are sometimes good to use with React? Or an overview of the
relationship between the frameworks?
- Hugo 是用 Go 编写的,构建了香草静态 HTML。例子:一个博客,但是你只需要写一次页眉和页脚。
- React 是用Javascript 编写的,是一个构建动态界面的前端库。 React 站点通常会为您提供一个空的 index.html 文件和一个 Javascript 文件,然后它将 运行 并在您的浏览器中动态地用内容填充 index.html 文件。示例:每次加载时都不一样的 Facebook Newsfeed。
- 但是如果你想写上面的示例博客,同样只写一次页眉和页脚,但习惯了 React 语法怎么办?如果您使用普通的 React,您的博客将下载一个空的 index.html 文件并在 Javascript 中用您的博客填充它。这对 SEO 和加载时间等不利。如果您仍想将其编译为香草静态 HTML – 这就是 Gatsby 的用途。
是否possible/ideal 将 Hugo 之类的东西与 React 一起使用?我知道盖茨比,但雨果也会工作吗?我对将两者结合起来了解有限,但我的理解是 Hugo 将用于所有模板和静态网页,然后 React 将用于 Web 应用程序类型的事物,以及那里某处的无头 CMS?有经验的人可以评论为什么 Hugo 或 Gatsby 有时很适合与 React 一起使用吗?或者框架之间关系的概述?
是的,
gatsby中有组件网页设计,
还有hugo的光速,
我也在纠结于这两者之间。
我不知道我会做什么,但我的想法是:
- 使用gatsby构建页面。您应该自己构建网站的每个页面(不要依赖路由)
- 使用带有 hugo 模板的
index.html
文件。 - 完成
这是构建 gatsby 页面后文件夹 public
的图片(输出):
更新:
你可以依赖路由。在上图中,每个组件文件夹都有自己的 index.html
,因此您也可以使用它们。
2021 年更新:
使用Next.JS。使用 Incremental Static Regeneration
功能,您甚至可以在不接触 Hugo 的情况下实现您想要的。
Is it possible/ideal to use something like Hugo with React? I am aware of Gatsby, but would Hugo work as well.
我们在 https://www.electrade.app 将 Hugo 与 React (create-react-app) 结合使用。所有页面都用于 hugo 静态页面,但如果你导航到 /quote,react SPA 加载并且你处于动态状态。所以是的,Hugo 也可以工作,但是你将拥有 2 种语言和 2 种语法。
combining the two [...] my understanding would be that Hugo would be used for all your templating and static web pages and then React would be used for the web application type of things
完全正确。
Can someone with experience comment why Hugo or Gatsby are sometimes good to use with React? Or an overview of the relationship between the frameworks?
- Hugo 是用 Go 编写的,构建了香草静态 HTML。例子:一个博客,但是你只需要写一次页眉和页脚。
- React 是用Javascript 编写的,是一个构建动态界面的前端库。 React 站点通常会为您提供一个空的 index.html 文件和一个 Javascript 文件,然后它将 运行 并在您的浏览器中动态地用内容填充 index.html 文件。示例:每次加载时都不一样的 Facebook Newsfeed。
- 但是如果你想写上面的示例博客,同样只写一次页眉和页脚,但习惯了 React 语法怎么办?如果您使用普通的 React,您的博客将下载一个空的 index.html 文件并在 Javascript 中用您的博客填充它。这对 SEO 和加载时间等不利。如果您仍想将其编译为香草静态 HTML – 这就是 Gatsby 的用途。