【问题标题】:Hugo site isn't starting locallyHugo 网站没有在本地启动
【发布时间】:2019-10-30 12:59:42
【问题描述】:

我目前正在尝试在本地建立一个 Hugo 网站,但没有显示任何内容。我想要更多的故障排除步骤或任何可以帮助我彻底重建的东西,这样我就不必将所有帖子都转移到 Google 网站上。

我尝试重新实例化该站点,使用hugo 重建它,使用hugo serverhugo server -D 启动服务器,但我只得到一个空白屏幕。

我的页面不是草稿,所以肯定应该显示一些内容。 public 或 index 文件夹可能会出错,但我不确定。

hugo version:Hugo Static Site Generator v0.48/extended darwin/amd64

go version:go version go1.11.2 darwin/amd64

config.toml:

baseURL = ""
languageCode = "en-us"
title = ""
theme = "ananke"

[menu]

  [[menu.main]]
    identifier = "Posts"
    name = "Posts"
    pre = "<i class='fa fa-road'></i>"
    url = "/posts/"
    weight = -100

[params]

    featured_image = "images/space-cat-wallpaper.jpg"
    twitter = ""

使用hugo构建页面时:


                   | EN  
+------------------+----+
  Pages            | 72  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     | 21  
  Processed images |  0  
  Aliases          |  1  
  Sitemaps         |  1  
  Cleaned          |  0  

Total in 88 ms

使用hugo server -D启动本地实例时:


                   | EN   
+------------------+-----+
  Pages            | 117  
  Paginator pages  |   5  
  Non-page files   |   0  
  Static files     |  21  
  Processed images |   0  
  Aliases          |   1  
  Sitemaps         |   1  
  Cleaned          |   0  

Total in 120 ms
Watching for changes in /Users/jschalz/Desktop/hugo-jschalz.github.io-2/{content,data,layouts,static,themes}
Watching for config changes in /Users/jschalz/Desktop/hugo-jschalz.github.io-2/config.toml
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

运行hugo -v --debug -D 后,我收到以下警告,然后是大量调试噪音:

WARN 2019/06/16 16:33:21 No translation bundle found for default language "en"
WARN 2019/06/16 16:33:21 Translation func for language en not found, use default.
WARN 2019/06/16 16:33:21 i18n not initialized, check that you have language file (in i18n) that matches the site language or the default language.

导航到 localhost:1313 给我一个空白屏幕。

【问题讨论】:

    标签: github-pages hugo


    【解决方案1】:

    hugo -v --debug -D可以告诉你更多

    其次,要确定是否生成了某些内容,请尝试:

    hugo server --renderToDisk --gc --cleanDestinationDir
    

    检查文件是否已创建(而不是在内存中提供)

    注意:我总是喜欢添加我的config.toml

    builddrafts = true 
    

    在启动项目时很有用,可以确保生成所有内容

    OP ladygremlin 确认in the comments

    我认为config.toml 中的builddrafts = true 修复了它!
    我也升级到了最新版本的hugo。

    【讨论】:

    • 我尝试了hugo -v --debug -D 并收到了一些警告,我将添加到原始帖子中。第二个命令仍然没有产生任何页面,但也没有说明它们是在内存中提供的,这可能更好。 :)
    • @ladygremlin 只要磁盘上没有生成页面...这确实是个问题。
    • @ladygremlin 除了警告之外,您的内容中确实有 md 文件,如 github.com/alex-shpak/hugo-book/issues/…?
    • @ladygremlin 您的本地路径文件夹是否有任何特殊字符? (如github.com/gohugoio/hugo/issues/3726
    • 我认为config.toml 中的builddrafts = true 修复了它!我还升级到了最新版本的hugo。谢谢!
    猜你喜欢
    • 2018-07-16
    • 1970-01-01
    • 2019-03-11
    • 2015-03-19
    • 2019-10-30
    • 1970-01-01
    • 1970-01-01
    • 2019-08-09
    • 2021-04-15
    相关资源
    最近更新 更多