Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upWorking with ox-hugo #699
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Bertbk
Sep 20, 2018
Seems that you don't have the right version of Hugo. You need Hugo 0.48 compiled with Go 1.11 (the latest point being important). See this issue for example
Are you on Debian or Archlinux ? If yes, then the Hugo package is still not updated.
Bertbk
commented
Sep 20, 2018
|
Seems that you don't have the right version of Hugo. You need Hugo 0.48 compiled with Go 1.11 (the latest point being important). See this issue for example Are you on Debian or Archlinux ? If yes, then the Hugo package is still not updated. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dhruvparamhans
Sep 20, 2018
I am on MacOS at the moment. On running hugo version I find that I do indeed have version 0.48 installed. Output for info:
Hugo Static Site Generator v0.48/extended darwin/amd64 BuildDate: unknown
I installed hugo via homebrew. Do I need to build hugo with Go?
dhruvparamhans
commented
Sep 20, 2018
|
I am on MacOS at the moment. On running I installed hugo via homebrew. Do I need to build hugo with Go? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kaushalmodi
Sep 20, 2018
@dhruvparamhans Can you post the Markdown file here so that someone can reproduce the issue? Looking at the error, looks like len is called on nil i.e. you don't have the post's tags set at all. I'm not sure where that len is called.
If it's in this theme, the theme needs to be fixed. But all of these are just guesses till I see the Markdown file.
kaushalmodi
commented
Sep 20, 2018
|
@dhruvparamhans Can you post the Markdown file here so that someone can reproduce the issue? Looking at the error, looks like If it's in this theme, the theme needs to be fixed. But all of these are just guesses till I see the Markdown file. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dhruvparamhans
Sep 20, 2018
Here is the markdown file generated from the org-file.
+++
title = "Test post"
author = ["Dhruv Sharma"]
draft = false
+++
## Here is a big heading {#here-is-a-big-heading}
This is some text
### Here is a sub-heading {#here-is-a-sub-heading}
This is some more text
This file is placed in the folder content/post. However, placing the file in the home folder doesn't give the same error.
dhruvparamhans
commented
Sep 20, 2018
|
Here is the markdown file generated from the org-file.
This file is placed in the folder |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kaushalmodi
Sep 20, 2018
@dhruvparamhans I confirm this to be a bug in this theme.
To reproduce error
# posts.org file in the exampleSite dir in this theme
#+hugo_base_dir: .
#+hugo_section: post
#+author:
* Post 1
:PROPERTIES:
:EXPORT_FILE_NAME: post-1
:END:
Hello
Do C-c C-e H A.
You get:
+++
title = "Post 1"
draft = false
+++
Helloand error:
ERROR 2018/09/20 09:23:44 Error while rendering "home" in "": template: index.html:4:3: executing "index.html" at <partial "widget_page...>: error calling partial: template: partials/widget_page.html:23:9: executing "partials/widget_page.html" at <partial $widget $par...>: error calling partial: template: partials/widgets/posts.html:65:51: executing "partials/widgets/posts.html" at <len .Params.tags>: error calling len: len of untyped nil
To bypass this bug
Add a tag to the post
# posts.org file in the exampleSite dir in this theme
#+hugo_base_dir: .
#+hugo_section: post
#+author:
* Post 1 :foo:
:PROPERTIES:
:EXPORT_FILE_NAME: post-1
:END:
Hello
Do C-c C-e H A.
You get:
+++
title = "Post 1"
tags = ["foo"]
draft = false
+++
Hello
and that error goes away.
@gcushen You should use {{ with .Params.tags }} instead of checking len.
kaushalmodi
commented
Sep 20, 2018
•
|
@dhruvparamhans I confirm this to be a bug in this theme. To reproduce error
Do You get: +++
title = "Post 1"
draft = false
+++
Helloand error:
To bypass this bugAdd a tag to the post
Do You get:
and that error goes away. @gcushen You should use |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kaushalmodi
Sep 20, 2018
This file is placed in the folder content/post. However, placing the file in the home folder doesn't give the same error.
That makes sense because grepping for len \.Params\.tag yields results showing this issue only in posts.html which I assume is used only for posts in content/post/:
layouts/partials/widgets/posts.html:34:52: {{ if and ($page.Params.tags_include) (lt (len .Params.tags) 1) }}
layouts/partials/widgets/posts.html:65:52: {{ if and ($page.Params.tags_include) (lt (len .Params.tags) 1) }}
kaushalmodi
commented
Sep 20, 2018
•
That makes sense because grepping for
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kaushalmodi
Sep 20, 2018
Here's the proposed fix:
diff --git a/layouts/partials/widgets/posts.html b/layouts/partials/widgets/posts.html
index c2cea39..21e40b9 100644
--- a/layouts/partials/widgets/posts.html
+++ b/layouts/partials/widgets/posts.html
@@ -31,8 +31,10 @@
{{ $.Scratch.Set "show_post" "1" }}
{{/* If `tags_include` is set, exclude posts with no tags. */}}
- {{ if and ($page.Params.tags_include) (lt (len .Params.tags) 1) }}
- {{ $.Scratch.Set "show_post" "0" }}
+ {{ with (not .Params.tags) }}
+ {{ with $page.Params.tags_include }}
+ {{ $.Scratch.Set "show_post" "0" }}
+ {{end}}
{{end}}
{{/* If `tags_exclude` is set, exclude posts. */}}
@@ -62,8 +64,10 @@
{{ $.Scratch.Set "show_post" "1" }}
{{/* If `tags_include` is set, exclude posts with no tags. */}}
- {{ if and ($page.Params.tags_include) (lt (len .Params.tags) 1) }}
- {{ $.Scratch.Set "show_post" "0" }}
+ {{ with (not .Params.tags) }}
+ {{ with $page.Params.tags_include }}
+ {{ $.Scratch.Set "show_post" "0" }}
+ {{end}}
{{end}}
{{/* If `tags_exclude` is set, exclude posts. */}}Aside: I see a lot of $.Scratch.Set use. As the minimum requirement for your theme is anyways 0.48, you might as well use the new variable re-assignment operator = and get rid of that Scratch cruft :)
kaushalmodi
commented
Sep 20, 2018
|
Here's the proposed fix: diff --git a/layouts/partials/widgets/posts.html b/layouts/partials/widgets/posts.html
index c2cea39..21e40b9 100644
--- a/layouts/partials/widgets/posts.html
+++ b/layouts/partials/widgets/posts.html
@@ -31,8 +31,10 @@
{{ $.Scratch.Set "show_post" "1" }}
{{/* If `tags_include` is set, exclude posts with no tags. */}}
- {{ if and ($page.Params.tags_include) (lt (len .Params.tags) 1) }}
- {{ $.Scratch.Set "show_post" "0" }}
+ {{ with (not .Params.tags) }}
+ {{ with $page.Params.tags_include }}
+ {{ $.Scratch.Set "show_post" "0" }}
+ {{end}}
{{end}}
{{/* If `tags_exclude` is set, exclude posts. */}}
@@ -62,8 +64,10 @@
{{ $.Scratch.Set "show_post" "1" }}
{{/* If `tags_include` is set, exclude posts with no tags. */}}
- {{ if and ($page.Params.tags_include) (lt (len .Params.tags) 1) }}
- {{ $.Scratch.Set "show_post" "0" }}
+ {{ with (not .Params.tags) }}
+ {{ with $page.Params.tags_include }}
+ {{ $.Scratch.Set "show_post" "0" }}
+ {{end}}
{{end}}
{{/* If `tags_exclude` is set, exclude posts. */}}Aside: I see a lot of |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gcushen
Sep 20, 2018
Owner
It appears that this third party tool does not respect Academic's archetypes (content templates)... If the appropriate data structure from the archetypes is used, there are no issues.
|
It appears that this third party tool does not respect Academic's archetypes (content templates)... If the appropriate data structure from the archetypes is used, there are no issues. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kaushalmodi
Sep 20, 2018
@gcushen It's less problem with the use of third party tool.
So a user has to use the theme archetype to make the theme work?
If a user manually types the following in content/post/foo.md:
+++
title = "Post 1"
draft = false
+++
Hello
they will get the same error.
My proposal fixes that issue in the current template.
kaushalmodi
commented
Sep 20, 2018
|
@gcushen It's less problem with the use of third party tool. So a user has to use the theme archetype to make the theme work? If a user manually types the following in
they will get the same error. My proposal fixes that issue in the current template. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kaushalmodi
Sep 20, 2018
The Hugo archetypes are a convenience feature.. they should not be made mandatory for the layouts to work.
Also looks like the fix is simple. Your archetypes simply force add an empty tags = [] (and many other things). The proposed fix doesn't need one to have an empty tags = [].
kaushalmodi
commented
Sep 20, 2018
•
|
The Hugo archetypes are a convenience feature.. they should not be made mandatory for the layouts to work. Also looks like the fix is simple. Your archetypes simply force add an empty |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gcushen
Sep 20, 2018
Owner
Thank you for refactoring the code to make it optional for users to use the archetype (content template), such as via hugo new post. I have just pushed the change.
My point is that Hugo itself always uses archetypes as templates for creating new content. It helps to form a consistent user experience if third party tools respect and align with this principle.
Aside: I see a lot of $.Scratch.Set use. As the minimum requirement for your theme is anyways 0.48, you might as well use the new variable re-assignment operator = and get rid of that Scratch cruft :)
Yes, this is the reason why we updated the framework to use Hugo v0.48 - some code is now written in this form :) Although, no one has yet retrospectively refactored older code to use the more concise form, so feel free to contribute if you like.
|
Thank you for refactoring the code to make it optional for users to use the archetype (content template), such as via My point is that Hugo itself always uses archetypes as templates for creating new content. It helps to form a consistent user experience if third party tools respect and align with this principle.
Yes, this is the reason why we updated the framework to use Hugo v0.48 - some code is now written in this form :) Although, no one has yet retrospectively refactored older code to use the more concise form, so feel free to contribute if you like. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kaushalmodi
Sep 21, 2018
Thank you for refactoring the code to make it optional for users to use the archetype (content template), such as via hugo new post. I have just pushed the change.
Awesome! Thank you.
@dhruvparamhans Please verify and close this issue.
My point is that Hugo itself always uses archetypes as templates for creating new content. It helps to form a consistent user experience
I respect that you use archetypes for users doing hugo new post/foo.md. But that shouldn't result in layout design causing errors like in this issue.
Look at this from a different angle. With this bug still not fixed, people wouldn't have been able to switch theme to this one easily even if one of their post missed tags = []. That's a major layout bug.
To Hugo, having tags = [] is the exact same as not having tags in the first place. The layouts should respect that too.
if third party tools respect and align with this principle.
The thing is that the third party (the Emacs ox-hugo package in this case) does not need archetypes at all. A lot of meta-data is auto-inferred from the Org mode structure. In essence, ox-hugo obsoletes Hugo archetypes for Org mode users.
Yes, this is the reason why we updated the framework to use Hugo v0.48 - some code is now written in this form :) Although, no one has yet retrospectively refactored older code to use the more concise form, so feel free to contribute if you like.
Glad to hear that. I don't use this theme, but I am happy to help with Go Templating syntax like in this issue when needed.
kaushalmodi
commented
Sep 21, 2018
Awesome! Thank you. @dhruvparamhans Please verify and close this issue.
I respect that you use archetypes for users doing Look at this from a different angle. With this bug still not fixed, people wouldn't have been able to switch theme to this one easily even if one of their post missed To Hugo, having
The thing is that the third party (the Emacs
Glad to hear that. I don't use this theme, but I am happy to help with Go Templating syntax like in this issue when needed. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kaushalmodi
Sep 21, 2018
@gcushen Do you want to add a simple test case like:
+++
title = "Post 1"
draft = false
+++
Hello
to ensure that the problem is not repeated?
kaushalmodi
commented
Sep 21, 2018
|
@gcushen Do you want to add a simple test case like:
to ensure that the problem is not repeated? |
dhruvparamhans commentedSep 19, 2018
I am having some difficulties with creating posts. I am using org-mode and then exporting the file using ox-hugo. However, I am unable to rebuild the site and receive the following error:
ERROR 2018/09/20 01:50:24 Error while rendering "home" in "": template: index.html:4:3: executing "index.html" at <partial "widget_page...>: error calling partial: template: partials/widget_page.html:23:9: executing "partials/widget_page.html" at <partial $widget $par...>: error calling partial: template: partials/widgets/posts.html:65:51: executing "partials/widgets/posts.html" at <len .Params.tags>: error calling len: len of untyped nilIs there an incompatibility between the template that the theme uses and the output generated by ox-hugo? I tried the same approach: ox-hugo-> md -> move to content folder and didnt face the same problem.
Thanks.