配置Hugo从DB内容生成网站
Hugo中是否有一个插件或其他内容允许Hugo从DB读取内容并生成站点,而不是从Markdown/Data Files读取数据?
Is there a plugin or something in Hugo that allows hugo to read content from DB and generate site, rather than reading data from markdown/data files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
开箱即用,雨果仅生成
html
(或XML
,或JSON
)表示您的Markdown文件。雨果哲学中有一些东西说可再现的建筑优先于其他事物 - 我不知道我在哪里看过,但是当我在寻找同一件事时,我已经看到了它。但是有一些方法可以使您更接近这一点。
transform.unmarshall
parses
json
,toml
,yaml
,xml
或csv
资源>资源和转换它们可以地图或阵列。但是您仍然需要一个本地文件来使用它。您可以做的一件事是将其递增到您的构建工作流中, 您使用雨果生成网站,您将添加一个步骤来获取数据并将其写入其中一个中的本地文件格式。
resources.getRemote
Resources.getRemote 向远程URL提出
http
请求,最近已添加到Hugo中。这样,您就无需在构建过程中迈出新的步骤即可抓取,格式化和将数据写入磁盘。相反,您会在模板中添加一些逻辑以从URL获取数据。当然,您需要HTTP端点,因此您仍然需要某种API。
Out of the box, Hugo only generates
HTML
(orXML
, orJSON
) representations of your Markdown files. There's something in Hugo's philosophy that says that reproducible builds take precedence over other things — I don't know where I've seen, but I have seen it at some point, when I was looking for the same thing you are.But there are some ways to get you closer to that.
transform.unmarshall
transform.unmarshal
parsesJSON
,TOML
,YAML
,XML
, orCSV
resources and converts them to maps or arrays. But you still need a local file to use it.One thing that you could do is to incroporate this into your build workflow and before you generate your site with Hugo, you would add a step to grab the data and write it to a local file in one of those formats.
resources.GetRemote
resources.GetRemote
makes anHTTP
request to a remote URL, and has recently been added to Hugo.This way, you wouldn't need to have a new step in the build process to grab, format, and write data to the disk; you would instead, add some logic in your templates to grab the data from a URL. Of course, you need that HTTP endpoint, so you still need some sort of API available.