verless / verless

A Static Site Generator designed for Markdown-based content with a focus on simplicity and performance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to apply custom "Type"

ArcherN9 opened this issue · comments

Description

Hi! I'm new to static website generation in general and I've been trying to learn Go. I thought verless would be a great starting point since I generally learn by going through existing code bases. My configurations may be incorrect, but I'd appreciate any help.

  • I created a new Type titled "topbar" and placed a topbar.html file under themes/<<mytheme>>/templates/topbar.html.
  • Declared custom page types under verless.yml.
types:
    topbar:
        template: topbar.html
  • Added a Type tag on my markdown:
---
Type: topbar
Img: /img/logo1.png
---
This is a sample
  • however, whenever I build and run my website, the layout always defaults to the content in list-page.html

More information:

  • I've added the following section in my topbar.html file.
{{if .Page.Img}}
<div id="logo">
    <img class="logo-1" src="{{ .Page.Img }}" alt="" title="">
</div>
{{end }}
  • If I keep the above configuration as is and run build and serve, the content from list-pge.html is served.
  • But If I modify the above section to:
{{if .Page.TestTag}}
<div id="logo">
    <img class="logo-1" src="{{ .Page.TestTag }}" alt="" title="">
</div>
{{end }}

I receive the following error on executing serve: Error: template: topbar.html:160:30: executing "topbar.html" at <.Page.TestTag>: can't evaluate field TestTag in type *model.Page. Does this indicate the yml configuration may be correct but something else is going wrong?

verless version

verless version v0.4.3

System information

  • OS: Mac OSX
  • Version: 10.14.6

Thanks for your bug report. I've also noticed this one today, and I'm pretty sure that this bug is caused by #181. Do you have the tags plugin enabled? If so, you can temporarily disable the plugin, continue development and activate it again once this bug is fixed.

@hmble or @ArcherN9 You both may fix that issue by resolving #181. First come first serve, because this thing is really annoying.

I don't have tag enabled. My verless.yml. Ignore the weird formatting - that's because of Vim. Too lazy to format it just for this.

 1 version: 0.1
2  site:
 1   meta:
+    ¦ logo: /img/logo1.png
 3   ¦ title: <<Retracted>>
 4   ¦ subtitle: <<Retracted>>
 5   ¦ description: <<Retracted>>
 6   ¦ author: <<Retracted>>
 7   ¦ base: "<<Retracted>>"
 8   # Settings for your website's navigation.
 9   nav:
10   ¦ items:
11   ¦ ¦ - label: Home
12   ¦ ¦ ¦ target: http://localhost:8080/
13   # Settings for your website's footer.
14   footer:
15   ¦ items:
16   ¦ ¦ - label: Home
17   ¦ ¦ ¦ target: http://localhost:8080/
~  theme: <<Retracted>>
+  # Declare custom page types.
+  types:
+    ¦topbar:
+    ¦ ¦ template: topbar.html
+
24 build:
~    overwrite: true

May I ask how your content structure roughly looks like and which particular file (location in content and filename) is affected?

+  types:
+    ¦topbar:
+    ¦ ¦ template: topbar.html

Are you sure those indentions are correct? The other ones look a bit different (and arguably "more correct"):

2  site:
 1   meta:
+    ¦ logo: /img/logo1.png

Hey @ArcherN9, did my my comment fix this for you? :-)