雨果未能建立网站,说它无法找到主题

时间:2016-11-06 12:48:40

标签: gitlab hugo

我正在尝试在Gitlab上部署一个hugo网站,但它返回以下错误:

if h >= 65 and h < 75:

主题&#34;奇怪的案例&#34;在hosts文件夹中,它有一个静态文件夹,这就是为什么我发现这个问题莫名其妙。在这里,我包括我为部署网站所采取的步骤(它说github因为这是我的第一次尝试):

WARN: 2016/11/04 14:57:24 hugo.go:547: Unable to find static directory for theme strange-case in /builds/joaoeira/hugo/themes/strange-case/static

最后的消息hugo给了我:

git submodule add https://github.com/ExchangeRate-API/strange-case.git
git remote add origin https://github.com/joaoeira/joaoeira.github.io.git
hugo -t strange-case
git add .
git commit -m "first commit"
git push origin master

任何猜测?

我的config.toml文件:

=============================================================
Your rendered home page is blank: /index.html is zero-length
* Did you specify a theme on the command-line or in your
"config.toml" file? (Current theme: "strange-case")
* For more debugging information, run "hugo -v"
=============================================================

我的.gitlab.ci.yml文件。注意&#34; hugo -t strange-case -v&#34;指定主题和所有:

baseurl = "https://joaoeira.gitlab.io"
title = "Lettuce be Cereal"
author = "João Eira"
copyright = "Your Copyright"
canonifyurls = true
paginate = 5
PygmentsCodeFences = false

googleAnalytics = ""

contentdir = "content/post"
layoutdir = "layouts"
publishdir = "public"
theme = "strange-case"

[params]
    colorScheme = "scheme-darkbrown"
    DateFormat = "2 Jan 2006"
    description ="João Eira is a Master's student in Economics at Universidade de Coimbra."
    sidebarDescription = "João Eira's personal blog"
    sidebarFreeText =  "\"Shared fictions are the necessary condition of social coordination.\""
    piwikSiteID = ""
    piwikURL = ""


[[menu.main]]
    name = "About"
    url = "http://joaoeira.com"

[[menu.main]]
    name = "Twitter"
    url = "http://twitter.com/joaoeira"

2 个答案:

答案 0 :(得分:1)

可能的解决方案

(!)确保在雨果的config.toml中更新您的baseUrl

就我而言,hugo可以在本地很好地渲染,但是当我部署到gitlab页面时却无法正常工作。

我怎么得到错误

最初,根据Hugo Quickstart,我将主题(ananke)安装在正确的位置(repo/thems/ananke)。但是,当我的站点未在gitlab页面上呈现时,我尝试将模块移至publicc,因为我担心该模块无法用于部署。那是我遇到与上述OP相同的错误。

但是,当将我的baseUrl设置为与gitlab页面提供的网址匹配(并将它们移回顶级themes目录)时,一切正常。 :)

免责声明

YMMV,但最后baseUrl是我所缺少的。我从Hugo快速入门和hugo教程中学到了有关部署到gitlab的所有其他信息。

答案 1 :(得分:0)

在我的情况下问题是子模块。我必须在 .gitmodules 中使用相对网址提及子模块。此外,变量GIT_SUBMODULE_STRATEGY必须设置为 .gitlab-ci.yml 中的recursive

要做到这一点,我在我的命名空间中分叉主题并使用下一个配置。

<强> .gitmodules

[submodule "themes/hugo-universal-theme"]
path = themes/hugo-universal-theme
url = ../hugo-universal-theme.git

<强> .gitlab-ci.yml

# All available Hugo versions are listed here: https://gitlab.com/pages/hugo/container_registry
image: registry.gitlab.com/pages/hugo:latest

variables:
  GIT_SUBMODULE_STRATEGY: recursive

pages:
  script:
  - hugo
  artifacts:
    paths:
    - public
  only:
  - master