{"body_class":"rp-body rp-section-post","section":"post","thisUrl":"https://regisphilibert.com/post/","title":"Regis Philibert | blog","translation_url":null}


Hugo Page Resources

and how to use them...

In this article we’ll cover Hugo 0.32’s Page Resources and its impact on the way we structure our content folders, what methods and properties it offers, how to use it in our templates and markdown and finally its current limitations and how we can circumvent them with the addition of a manifest array directly in our Page’s Front Matter.

Pure CSS Masonry in 2018?

With those awesome css layout systems now available (Flexbox, Mutli-column, Grid), one must wonder if they cannot help us build the masonry grid every client has been asking for the last couple of years. Let’s review what a masonry layout is and how those modern options could help us build it

Hugo Translator

Go Template is the templating language used by Hugo and other Go systems. Now it is not Twig or Blade or Liquid, don’t get fooled by the familiar curlies. It is a far stretch from those well known Templating Language out there…

{{ printf "Hello %s %s. %s" $firstname (slicestr $middlename 0 1) $lastname }}

What is this 😨

{{ if or (eq firstname 'George') (eq firstname 'Daniel') }}

or that ? 😱

The first time you’re gonna stumble on the syntax above may be a bit deconcerting if you come from more conventional languages.

I spent a lot a time trying to figure out how best to use Go Template.

Using comparison with more familiar syntaxes, I wrote this modest article to try and help unveil the misteries of Go Template

Hugo .Scratch explained

Working variables in Hugo can be complicated when coming from classic languages.

What you usually do :

$greetings = "Good Morning";
if($sky == "dark"){
	$greetings = "Good Night";
// Or even better:
$greetings = $sky == "dark" ? "Good Night : Good Morning";

That next bit of code would be tempting :

{{ $greetings := "Good Morning" }}
{{ if eq $sky "dark" }}
	{{ $greetings := "Good Night" }}
{{ end }}
{{ $greetings }}

But that won’t happen 😞

The only way to override variables or attach any kind of value to a .Page object is to use .Scratch

.Scratch is a life saver but its documentation is a bit light if, like me, you are not comfortable with the Go language.

Here is my take about Hugo’s .Scratch and how it can help you.