Hammer Beta Support for High Sierra & Mojave Available Download.

Buy Hammer
Download
Features
Take the tour
Templates
Browse gallery
Docs
Read up
News + Updates
All the latest about Hammer

Variables

Show Menu

With Hammer, you can set variables in your pages that you can use again and again. These can be especially useful if you need to set something that comes in from another include that you use in multiple templates. You could use variables in Hammer to set a page title, an id attribute for the body or a class attribute in your navigation. You create a variable using the line below:

variable-set

You would then set the variable by using:

variable1

In this case, we could use this $title variable to set a title tag in a header include for each of our pages. In _header.html (our head include) we would create the variable:

variable3

And then in our about.html file we could make our page title "My About Page" by just setting the variable like this at the top of the file:

variable4

You can also set a default value to be used by a variable in case a page doesn't specify a value for it:

variable5

Have a question, want to beta test new releases or have an issue you're stuck with?

Join our supportive community Slack Team and get in touch with us directly. We love to help!

Free Trial
Buy Hammer
Anvil is a beautiful menubar app that can run your Hammer builds under local .dev URL’s - great if you’re using web services like Typekit. Find out more and download it for free at anvilformac.com