dongzhan2461 2017-07-26 04:28
浏览 71
已采纳

Hugo如何维护站点范围内的数据,例如.Site.AllPages?

I'm looking for some bite-sized examples on how Hugo might be managing site-wide data, like Site.AllPages.

Specifically, Hugo seems too fast to be reading in every file and it's metadata, before beginning to generate pages and making things like .Site.AllPages available -- but obviously that has to be the case.

Are Ruby (Jekyll) and Python (Pelican) really just that slow, or is there some specific (algorithmic) method that Hugo employs to generate pages before everything is ready?

  • 写回答

2条回答 默认 最新

  • dswsl2016 2017-07-26 09:31
    关注

    There is no magic, and Hugo does not start any rendering until the .Site.Pages etc. collections are filled and ready.

    Some key points here:

    • We have a processing pipeline where we do concurrent processing whenever we can, so your CPUs should be pretty busy.
    • Whenever we do content manipulation (shortcodes, emojis etc.), you will most likely see a hand crafted parser or replacement function that is built for speed.
    • We really care about the "being fast" part, so we have a solid set of benchmarks to reveal any performance regressions.
    • Hugo is built with Go -- which is really fast, and have a really great set of tools for this (pprof, benchmark support etc.)

    Some other points that makes the hugo server variant even faster than the regular hugo build:

    • Hugo uses a virtual file system, and we render directly to memory when in server/development mode.
    • We have some partial reloading logic in there. So, even if we render everything every time, we try to reload and rebuild only the content files that have changed and we don't reload/rebuild templates if it is a content change etc.

    I'm bep on GitHub, the main developer on Hugo.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 MATLAB yalmip 可转移负荷的简单建模出错,如何解决?
  • ¥15 数学的三元一次方程求解
  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?