雨果未能建立网站,称无法找到主题 [英] Hugo fails to build site, saying it is unable to find a theme
问题描述
我正在尝试在Gitlab上部署一个雨果网站,但它返回以下错误:
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
主题"strange-case"位于主题文件夹内,并且那里有一个静态文件夹,这就是为什么我发现这个问题令人困惑的原因.在这里,我包括了部署网站的步骤(它是github,因为这是我的第一次尝试):
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"
=============================================================
有没有猜到?
我的config.toml文件:
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"
我的.gitlab.ci.yml文件.请注意指定主题和所有内容的"hugo -t奇怪的情况下-v":
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
推荐答案
可能的解决方案
(!)确保在雨果的config.toml中更新您的
baseUrl
就我而言,hugo可以在本地很好地渲染,但是当我部署到gitlab页面时却无法正常工作.
In my case, hugo was rendering fine locally, but not working when I deployed to gitlab pages.
最初,根据Hugo Quickstart,我将主题(ananke)安装在正确的位置(repo/thems/ananke
).但是,当我的站点未在gitlab页面上呈现时,我尝试将模块移至publicc,因为我担心该模块无法用于部署.那是我遇到与上面的OP相同的错误.
Originally, I had my theme (ananke) installed in the correct place (repo/thems/ananke
) according to the Hugo Quickstart. But, when my site didn't render on gitlab pages, I tried moving the module into publicc because I was afraid it wasn't available to the deployment. That's when I got the same error as the OP above.
但是,当将我的baseUrl
设置为与gitlab页面提供的网址匹配(并将它们移回顶级themes
目录)时,一切正常. :)
But, when set my baseUrl
to match the url provided by gitlab pages (and moved my them back into the top level themes
directory) everything worked. :)
YMMV,但最终我只缺少了baseUrl
.我从Hugo快速入门和hugo教程中学到了有关部署到gitlab的所有其他信息.
YMMV, but in the end the baseUrl
was all I was missing. Everything else I learned from the Hugo quickstart and hugo tutorial on deploying to gitlab.
这篇关于雨果未能建立网站,称无法找到主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!