Big Image Sample

Using Multiple Images

Big Image Sample

Using Multiple Images

The image banners at the top of the page are refered to as “bigimg” in this theme. They are optional, and one more more can be specified. If more than one is specified, the images rotate every 10 seconds. In the front matter, bigimgs are specified using an array of hashes.

A single bigimg can be specified in the front matter by the following YAML:

bigimg: [{src: "/desentropia/img/triangle.jpg", desc: "Triangle"}]

Multiple bigimgs can be specified in the front matter by the following YAML:

bigimg: [{src: "/desentropia/img/triangle.jpg", desc: "Triangle"},
         {src: "/desentropia/img/sphere.jpg", desc: "Sphere"},
         {src: "/desentropia/img/hexagon.jpg", desc: "Hexagon"}]

Also note that the description field is optional, and images could instead be specified by:

bigimg: [{src: "/desentropia/img/triangle.jpg"},
         {src: "/desentropia/img/sphere.jpg"},
         {src: "/desentropia/img/hexagon.jpg"}]

The above YAML array of hashes were written in “flow” style. However when generating a new page or post with hugo new post/mypost.md, hugo may interpret the archetype for bigimg in the default YAML style. Defining multiple bigimg’s complete with descriptions in this style would be specified by:

bigimg:
- {src: "/desentropia/img/triangle.jpg", desc: "Triangle"}
- {src: "/desentropia/img/sphere.jpg", desc: "Sphere"}
- {src: "/desentropia/img/hexagon.jpg", desc: "Hexagon"}

Additional information can be found in this YAML tutorial.

DEMO CODE

The following are two code samples using syntax highlighting.

The following is a code sample using triple backticks ( ``` ) code fencing provided in Hugo. This is client side highlighting and does not require any special installation.

    var num1, num2, sum
    num1 = prompt("Enter first number")
    num2 = prompt("Enter second number")
    sum = parseInt(num1) + parseInt(num2) // "+" means "add"
    alert("Sum = " + sum)  // "+" means combine into a string

The following is a code sample using the “highlight” shortcode provided in Hugo. This is server side highlighting and requires Python and Pygments to be installed.

    var num1, num2, sum
    num1 = prompt("Enter first number")
    num2 = prompt("Enter second number")
    sum = parseInt(num1) + parseInt(num2) // "+" means "add"
    alert("Sum = " + sum)  // "+" means combine into a string

And here is the same code with line numbers:

1    var num1, num2, sum
2    num1 = prompt("Enter first number")
3    num2 = prompt("Enter second number")
4    sum = parseInt(num1) + parseInt(num2) // "+" means "add"
5    alert("Sum = " + sum)  // "+" means combine into a string
6
comments powered by Disqus