kaushalmodi / hugo-bare-min-theme

A bare minimum theme for Hugo (https://gohugo.io) to help develop and debug Hugo sites -- https://hugo-bare-min.netlify.com/,
https://hugo-sandbox.netlify.com/
MIT License
80 stars 16 forks source link

Errors on site without expected parameters set #1

Closed paskal closed 6 years ago

paskal commented 6 years ago

Hello!

$subj, when trying to run this theme against my blog source I get following (and site won't render at all):

Building sites … ERROR 2018/03/20 14:45:17 Error while rendering "page" in "": template: /srv/hugo/themes/hugo-bare-min-theme/layouts/_default/single.html:101:51: executing "/srv/hugo/themes/hugo-bare-min-theme/layouts/_default/single.html" at <replaceRE>: wrong number of args for replaceRE: want 3 got 2
ERROR 2018/03/20 14:45:17 Error while rendering "page" in "post/": template: /srv/hugo/themes/hugo-bare-min-theme/layouts/_default/single.html:101:51: executing "/srv/hugo/themes/hugo-bare-min-theme/layouts/_default/single.html" at <replaceRE>: wrong number of args for replaceRE: want 3 got 2
ERROR 2018/03/20 14:45:18 Error while rendering "taxonomy" in "": template: /srv/hugo/themes/hugo-bare-min-theme/layouts/_default/list.html:101:51: executing "/srv/hugo/themes/hugo-bare-min-theme/layouts/_default/list.html" at <replaceRE>: wrong number of args for replaceRE: want 3 got 2
ERROR 2018/03/20 14:45:18 Error while rendering "home" in "": template: /srv/hugo/themes/hugo-bare-min-theme/layouts/index.html:101:51: executing "/srv/hugo/themes/hugo-bare-min-theme/layouts/index.html" at <replaceRE>: wrong number of args for replaceRE: want 3 got 2
ERROR 2018/03/20 14:45:18 Error while rendering "section" in "": template: /srv/hugo/themes/hugo-bare-min-theme/layouts/_default/list.html:101:51: executing "/srv/hugo/themes/hugo-bare-min-theme/layouts/_default/list.html" at <replaceRE>: wrong number of args for replaceRE: want 3 got 2
ERROR 2018/03/20 14:45:18 Error while rendering "taxonomyTerm" in "": template: /srv/hugo/themes/hugo-bare-min-theme/layouts/_default/terms.html:101:51: executing "/srv/hugo/themes/hugo-bare-min-theme/layouts/_default/terms.html" at <replaceRE>: wrong number of args for replaceRE: want 3 got 2

Change detected, rebuilding site
2018-03-20 14:46:02.673 +0000
Source changed "/srv/hugo/content/post/2018-03-19-lust-for-text-life.markdown": WRITE
ERROR 2018/03/20 14:46:02 Error while rendering "page" in "post/": template: /srv/hugo/themes/hugo-bare-min-theme/layouts/_default/single.html:101:51: executing "/srv/hugo/themes/hugo-bare-min-theme/layouts/_default/single.html" at <replaceRE>: wrong number of args for replaceRE: want 3 got 2
ERROR 2018/03/20 14:46:02 Error while rendering "home" in "": template: /srv/hugo/themes/hugo-bare-min-theme/layouts/index.html:101:51: executing "/srv/hugo/themes/hugo-bare-min-theme/layouts/index.html" at <replaceRE>: wrong number of args for replaceRE: want 3 got 2
Total in 299 ms

The reason is likely some absent or misconfigured .Site. parameter but you can't tell it from error message, I guess input parameters handling could be improved.

kaushalmodi commented 6 years ago

You need to define the .Site.Params.source variable as listed in the README:

  [Params.source]
    url = "https://your/site/repo/url" # Mandatory, used in bare_min single.html, baseof.html

diff --git a/blog/config.json b/blog/config.json
index c8b074e..72bc626 100644
--- a/blog/config.json
+++ b/blog/config.json
@@ -25,7 +25,11 @@
     "tag": "tags"
   },
   "params": {
-    "dateformat": "Jan 2, 2006"
+    "dateformat": "Jan 2, 2006",
+    "source": {
+      "url": "https://github.com/paskal/terrty",
+      "md_dir": "blog/content"
+    }
   },
   "author": {
     "name": "Dmitry Verhoturov"

So it works after the above change.

That allows creating of that Markdown source link as shown below.

image

kaushalmodi commented 6 years ago

I'll look into making the .Site.Params.source optional; tracking that in https://github.com/kaushalmodi/hugo-bare-min-theme/issues/2.

paskal commented 6 years ago

Requiring this parameter looks as an overkill for "bare minimum" theme and this feature which looks something which should be optional from the beginning. Thanks for quick reaction! I'll be glad to test the change when you'll make it.

kaushalmodi commented 6 years ago

This theme is meant for theme debug! Switching between the Markdown source and the HTML output is very critical for my flow. I can understand if that's not your flow, and so have opened the other issue for that. But having the markdown source link does count as "bare minimum" for me.

kaushalmodi commented 6 years ago

I'll be glad to test the change when you'll make it.

Give it a try again.

paskal commented 6 years ago

Thanks, it works without a single error now! You've first fixer of ~40 reported issues today:)

kaushalmodi commented 6 years ago

Well, now that you have this theme working, use it and understand the Hugo internals better, and starting sending in PR's to fix your ~40 issues 😃 !

paskal commented 6 years ago

Talking seriously, checking 200 hugo themes for common errors and reporting them to make world a better place for everyone instead of working on just one theme I use is the maximum effort I could afford at the moment and it's unlikely to change. 4 full hours are gone and only 74 of 202 processed. Nicest thing I can stumble upon is the theme without a single error and with properly rendered main page, images and source code blocks:)

kaushalmodi commented 6 years ago

Nicest thing I can stumble upon is the theme without a single error and with properly rendered main page, images and source code blocks :)

I haven't used the BluestNight theme, but by the looks of the level and detail of documentation ( https://bluestnight.shadow53.com/ ), it looks great!


If you like code blocks, images, etc on my blog https://scripter.co, you can look at my hand-stitched theme refined.. or my Alabaster-forked onyx theme which I use for https://ox-hugo.scripter.co/.

Again, all theme authors would design a theme that would suit their site, which would probably need certain amount of site config params.. so if you use a theme, you very likely would need to set those params too to unbreak that theme.


only 74 of 202 processed.

What's your goal? But anyways, thanks for doing this.

paskal commented 6 years ago

I'm trying to make themes friendlier at least for my scenario (someone migrated from octopress and trying to check which theme fits him or her without making configuration changes for every single one of them).

Themes you mention looks crazy good, could you please add them to https://github.com/gohugoio/hugoThemes for better visibility?


Regarding the goal, I've tried to pick good-looking themes from theme site and found out half of them not working for me for different reasons, are from ones which work quite a few have problems with fonts \ images \ source code listings \ taxonomy. Also I found what author decide for himself what tags to add to the theme, and not all blog-tagged themes are actual blogs, and not all blog themes marked as blog. I've decided to go an extra mile and check them all visually, then I found out 3-4 common problems which could be (relatively) cheaply reported and will make theme friendlier after fix.

When someone completely newbie will try your theme, he or she won't get scary Error while rendering error and that increase the chance they will settle on your theme. I wonder how many people had similar problems before but didn't bother to report and just moved on.

Standardization is a good thing, and I'm applying effort to show authors how they could make their themes work more reliable with less requirements to get something you could try out with minimal functionality. It was much better with Octopress because of stricter theme restrictions, Hugo have much more freedom and what we have at the moment is a mess.