asurcodes / amperage

Blazing fast SEO optimized GoHugo theme with native AMP, structured data, search, service workers and i18n out of the box! :zap:

Home Page:https://themes.gohugo.io/amperage/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Featured Images

sharedphysics opened this issue · comments

Hi, I'm having some trouble adding featured images on posts (images that show up in the preview stream before someone clicks into a post).

I tried to replicate what you had here - https://github.com/asurbernardo/amperage/blob/master/exampleSite/content/test/yet-another-test-post.md - but I think I may not have added the proper configurations elsewhere, because hugo started running into compiling errors something about missing colons after [image] src = "/images/share-banner.png"

I didn't see any documentation about this and every theme seems to handle this differently, so hoping you can assist?

commented

Hello @sharedphysics, thank you for the report.

Have you copy/pasted by any chance the toml frontmatter from the GitHub markdown interpretation?

Try copying it from the raw file instead: https://raw.githubusercontent.com/asurbernardo/amperage/master/exampleSite/content/test/yet-another-test-post.md. Remember that the frontmatter needs to have a valid toml format. (https://github.com/toml-lang/toml#example)

Tell me if that's the case, if it isn't it would be really helpful if you posted the error you are getting 😄

So I think that solved it, but I'm not sure why!

I took your entire example toml and got it to work:

+++
draft = false
date = "2019-09-16T12:33:32+02:00"
publishdate = "2019-09-16T12:33:32+02:00"

title = "Yet another test post"

description = "Test description"

summary = "Test summary."

tags = ['Tag']

keywords = ['amperage', 'test', 'post']

[amp]
    elements = []

[author]
    name = "Roman"

[image]
    src = "/images/msg.png"
+++ 

But when I was using the standard (default) Hugo markdown template, it wasn't working...

---
title: "Test Title"
date: 2018-02-03

[author]
    name = "Roman"

[image]
    src = "/images/msg.png"
---

The error I was getting was:

Rebuild failed:
"/hugo_site/content/posts/msg-bills.md:7:1": failed to unmarshal YAML: yaml: line 5: could not find expected ':'
image
Hugo Static Site Generator v0.62.2/extended darwin/amd64 BuildDate: unknown

A beginner mistake, but can you help me understand why?

commented

@errorstates You are mixing file formats, in the frontmatter you can wrap it with --- for yaml and with +++ for toml. You are basically trying to configure a yaml using the toml format.

This has nothing to do with the theme itself.

Please let's try from now on to keep the issues focused on one thing at a time as well.