Problems injecting variables into pages


#1

I’m a really new user to Hugo, but I created a site, added a theme, created some pages, and initially found things pretty straightforward. I’ve read the documentation a few times and I’m struggling to inject a variable (or other dynamic-ish content) into a page.

I’ve seen numerous examples using examples such as:

{{ .Title }}

but then I put them into a file, I literally see {{ .Title }}.

I get the same results with {{ .TableOfContents }} and {{ partial "test.md" . }}. The only success I saw was with [Next]({{< ref "my-2nd-post.md" >}} "Here")

I see things changing when in the browser when I make the change while hugo server is running, so I know the pages are being processed, but I’m confused as to why I’m not seeing the expected results.

I’ve even cloned the official Hugo docs and tried the same thing with them, but with a similar lack of results. For example:

---
title: Hugo Documentation
linktitle: Hugo
description: Hugo is the world's fastest static website engine. It's written in Go (aka Golang) and developed by bep, spf13 and friends.
date: 2017-02-01
publishdate: 2017-02-01
menu:
main:
parent: "section name"
weight: 01
weight: 01 #rem
draft: false
slug:
aliases: []
toc: false
layout: documentation-home
---
Hugo is the **world's fastest static website engine.** It's written in Go (aka Golang) and developed by [bep](https://github.com/bep), [spf13](https://github.com/spf13) and [friends](https://github.com/gohugoio/hugo/graphs/contributors). 

{{ .Title }}

Below you will find some of the most common and helpful pages from our documentation.

Any pointers would be appreciated!

Thanks!


#2

Hello,

You need to enable Inline Shortcodes for this sort of thing.


#3

@onedrawingperday, thanks so much for your reply:

The good news is that your post gave me enough information to understand how to use /layout/shortcodes to build what I was looking for. Thanks for that!

The bad news is that when I added “enableInlineShortcodes = true” into my config.toml file, it didn’t seem to have any impact. I added it between the baseURL and languageCode directives:

baseURL = "https://www.mysite.com" enableInlineShortcodes = true languageCode = "en-us"
Once I’ve really understood this, I’ll branch the documentation and try to extend the Quick Start guide.

Thanks!


#4

Even if you enable Inline Shortcodes just using the .Title variable on its own in a content file as you posted above will not work.

You need to follow the Example in the Docs and other examples in the forum (hint: use the forum search)