4

I am trying to deploy a hugo website on Gitlab but it returns the following error:

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

The theme "strange-case" is inside the themes folder, and it has a static folder there which is why I am finding this problem baffling. Here I include the steps I took to deploy the website (it says github because that was my first try):

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

The final message hugo gives me:

=============================================================
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"
=============================================================

Any guesses?

My config.toml file:

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"

My .gitlab.ci.yml file. Note the "hugo -t strange-case -v" specifying the theme and all:

image: alpine:3.4

before_script:
  - apk update && apk add openssl
  - wget https://github.com/spf13/hugo/releases/download/v0.16/hugo_0.16_linux-64bit.tgz
  - echo "37ee91ab3469afbf7602a091d466dfa5  hugo_0.16_linux-64bit.tgz" | md5sum -c
  - tar xf hugo_0.16_linux-64bit.tgz && cp ./hugo /usr/bin
  - hugo version

test:
  script:
  - hugo
  except:
  - master

pages:
  script:
  - hugo -t strange-case -v
  artifacts:
    paths:
    - public
  only:
  - master
4

2 回答 2

1

可能的解决方案

(!)确保更新你baseUrl在 hugo 的 config.toml

在我的情况下,hugo 在本地渲染得很好,但是当我部署到 gitlab 页面时无法正常工作。

我是如何得到错误的

repo/thems/ananke最初,根据 Hugo 快速入门,我将主题 (ananke) 安装在正确的位置 ( )。但是,当我的网站没有在 gitlab 页面上呈现时,我尝试将模块移动到 publicc 中,因为我担心它对部署不可用。那时我遇到了与上面的 OP 相同的错误。

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

免责声明

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

于 2020-01-29T05:30:21.587 回答
0

就我而言,问题出在子模块上。我必须在.gitmodules中使用相对 url 提及子模块。变量也GIT_SUBMODULE_STRATEGY必须设置为recursive.gitlab -ci.yml

为此,我在命名空间中分叉了主题并使用了下一个配置。

.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
于 2018-03-25T13:57:50.600 回答