1

I am trying out a Hugo theme and what happened was when I used the command hugo server, I see the following error message.

Building sites … WARN 2020/07/20 14:33:07 Page.URL is deprecated and will be removed in a future release. Use .Permalink or .RelPermalink. If what you want is the front matter URL value, use .Params.url
ERROR 2020/07/20 14:33:07 render of "taxonomy" failed: "D:\Hugo\bin\my_conf\themes\devfest-theme-hugo\layouts\_default\baseof.html:7:3": execute of template failed: template: taxonomy/list.html:7:3: executing "taxonomy/list.html" at <readFile "static/icons.svg">: error calling readFile: file "static\\icons.svg" does not exist
ERROR 2020/07/20 14:33:07 render of "home" failed: "D:\Hugo\bin\my_conf\themes\devfest-theme-hugo\layouts\_default\baseof.html:7:3": execute of template failed: template: index.html:7:3: executing "index.html" at <readFile "static/icons.svg">: error calling readFile: file "static\\icons.svg" does not exist
Built in 100 ms
Error: Error building site: failed to render pages: render of "taxonomy" failed: "D:\Hugo\bin\my_conf\themes\devfest-theme-hugo\layouts\_default\baseof.html:7:3": execute of template failed: template: taxonomy/list.html:7:3: executing "taxonomy/list.html" at <readFile "static/icons.svg">: error calling readFile: file "static\\icons.svg" does not exist

It seems saying that I misplaced some of the template files. I wonder if I have installed the theme correctly, or something I misunderstood?

What I have Done

  1. Installed hugo and confirmed it is installed.
  2. Created a new site called my-conf (Just trying out) and the themes directory.
  3. I've cloned the repository into my themes directory. I am using GitHub Desktop on Windows.
  4. Added the theme information using theme = "devfest-theme-hugo".
  5. Used the command hugo server.
SHY.John
  • 115
  • 3
  • 8

1 Answers1

2

Ideally, you would add the themes as a submodule, as in the documentation, and the theme page itself:

hugo new site my-conf
cd my-conf
mkdir themes
git submodule add https://github.com/GDGToulouse/devfest-theme-hugo.git themes/devfest-theme-hugo

And add it to your configuration (which you seem to have done):

echo 'theme = "ananke"' >> config.toml

Then, regarding readFile:

To use the readFile function in your templates, make sure the path is relative to your Hugo project’s root directory:

{{ readFile "/content/templates/local-file-templates" }}

In the template: layouts/_default/baseof.html seems to have the right path.

Yet, looking at the history of GDGToulouse/devfest-theme-hugo/layouts/_default/baseof.html, I see it has changed during a commit "WIP 2020".

The version before that commit included:

{{ readFile "themes/devfest-theme-hugo/static/icons.svg" | safeHTML }}

Which, from the discussion, seems to work better!

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. So cloning is not the same as adding submodules right? – SHY.John Jul 22 '20 at 00:35
  • @SHY.John No: by cloning in a parent repo, said parent repository would not memorize *where* your nested repository (the theme) is coming from. – VonC Jul 22 '20 at 05:41
  • I am using Github Desktop, are you aware if I can add submodules from there? – SHY.John Jul 23 '20 at 03:21
  • @SHY.John From what I can read in https://github.com/desktop/desktop/issues/708, this does not seem to be fully supported. `git submodule add`, in command line, remains the safest option. – VonC Jul 23 '20 at 05:12
  • Oh, what happened is I've tried using `git` and doesn't say it's a valid command. But I suppose the terminal command `git` comes with the GitHub Desktop right? – SHY.John Jul 23 '20 at 11:37
  • 1
    @SHY.John No: https://stackoverflow.com/a/54679083/6309. You need Git for Windows for that: https://stackoverflow.com/a/54104048/6309 – VonC Jul 23 '20 at 12:14
  • Thanks, once I get this done tmr I'll choose you as correct answer. – SHY.John Jul 26 '20 at 11:11
  • @SHY.John Can you try the same repo+git submodule add, but outside of `D:\Hugo\bin`? In `D:\myWebSiteProject`? – VonC Jul 27 '20 at 07:58
  • Oh, my website is outside of `D:\Hugo\bin`. So it shouldn't be a problem. – SHY.John Jul 29 '20 at 00:48
  • @SHY.John Does your "`D:\myWebSiteProject`" has a `.git` subfolder? – VonC Jul 29 '20 at 05:15
  • Nope, I have a `.gitmodule` file, but not a folder relating to Git. – SHY.John Jul 29 '20 at 08:08
  • @SHY.John That might be a problem, for executing any git command in it. – VonC Jul 29 '20 at 08:12
  • It seems that the folder exists but hidden. – SHY.John Jul 29 '20 at 08:33
  • @SHY.John Then can you share a screenshot of the command you type, and the resulting error message? (in "`D:\myWebSiteProject`") – VonC Jul 29 '20 at 10:50
  • Here you go. :) – SHY.John Jul 29 '20 at 11:44
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/218819/discussion-between-vonc-and-shy-john). – VonC Jul 29 '20 at 12:31
  • @SHY.John I have edited the answer to reflect the conclusion of the discussion. – VonC Jul 29 '20 at 12:54