đŸ“Ŋī¸

reveal-hugo

A Hugo theme for creating Reveal.js presentations.

~ made by @dzello ~

What’s included?

  • All Reveal.js HTML, CSS and JS (v3.7.0)
  • All out-of-the-box Reveal.js themes
  • Two custom Reveal.js themes (including this one)

Features

  • Write slides in Markdown in one or more files
  • Shorcodes for fragments, sections, slides & more
  • All Reveal.js parameters can be customized
  • Any Hugo section can be output as a presentation

Usage

Prerequisite

First, add this to your config.toml:

[outputFormats.Reveal]
baseName = "index"
mediaType = "text/html"
isHTML = true

Presentation at site root

Create content/_index.md:

+++
outputs = ["Reveal"]
+++

# Slide 1

Hello world!

Add slides in same file

Separate them by ---:

# Slide 1

Hello world!

---

# Slide 2

Hello program!

Add slides with other files

Add slides to content/home/*.md

+++
weight = 10
+++

# Slide 3

---

# Slide 4

💡 Tip: Use weight to specify the order that files should be added.

Presentation at ‘/{section}/’

In content/{section}/_index.md:

+++
outputs = ["Reveal"]
+++

# Slide 1

---

# Slide 2

Add slides from other files in content/{section}/*.md

+++
weight = 10
+++

# Slide 3

---

# Slide 4

💡 Tip: Use weight to specify the order that files should be added.

Configuration

Place configuration values in config.toml or a presentation’s front matter (_index.md).

Reveal.js themes

Themes control the look and feel of your presentation. Set the theme param to any valid Reveal.js theme.

[params.reveal_hugo]
theme = "moon"

Use a custom theme

To use a custom Reveal.js theme, place the CSS file in the static directory and set the custom_theme param.

[params.reveal_hugo]
custom_theme = "reveal-hugo/themes/robot-lung.css"

Bundled themes

reveal-hugo comes with 2 extra Reveal.js themes:


They live in the static/reveal-hugo/themes folder and also on Github.

Reveal.js params

Set snakecase versions of Reveal.js params, which will be camelized and passed to Reveal.initialize.

[params.reveal_hugo]
history = true
slide_number = true
transition = 'zoom'
transition_speed = 'fast'

Full list of params

highlight.js themes

To change the syntax highlighting theme, set the highlight_theme to a valid highlight.js theme name.

[params.reveal_hugo]
highlight_theme = "zenburn"

Extending the layout

Use partials to add HTML to the page for one or all presentations at a time.

💡 This is the recommended way to add script and style tags to customize your presentations.

Here is where partials go for different presentations and places on the page.

Presentation Before </head> Before </body>
All reveal-hugo/head.html reveal-hugo/body.html
Root home/reveal-hugo/head.html home/reveal-hugo/body.html
Section {section}/reveal-hugo/head.html {section}/reveal-hugo/body.html

Custom CSS Example

In home/reveal-hugo/head.html:

<style>
.reveal section h1 {
  color: blue;
}
</style>

Custom JS Example

In home/reveal-hugo/body.html:

<script type="text/javascript">
Reveal.addEventListener('slidechanged', function(event) {
  console.log("🎞ī¸ Slide is now " + event.indexh);
});
</script>

Shortcodes

Hugo’s shortcodes are similar to functions or templates that extend what you can do with Markdown.

Shortcode documentation

Fragment

The fragment shortcode makes content appear incrementally.

{{% fragment %}} One {{% /fragment %}}
{{% fragment %}} Two {{% /fragment %}}
{{% fragment %}} Three {{% /fragment %}}

One Two Three

Frag

The frag shortcode is more terse than fragment. It accepts a c attribute.

{{< frag c="One" >}}
{{< frag c="Two" >}}
{{< frag c="Three" >}}

One Two Three

Both fragment and frag accept two additional parameters:

  • class: sets the class of the wrapping span element
  • index: controls the order in which sections will appear

Section

The section shortcode groups slides into a vertical display.


use the down arrow or swipe down to continue
đŸ”Ŋ

Put the shortcode around the slides you want to group together.

{{% section %}}

## Section slide 1

---

## Section slide 2

{{% /section %}}

Keep going down.

That’s it!

Use the right arrow or swipe right to continue.

Slide

Use this shortcode when you need to customize slide attributes like id, class, background color and transition.

Slide

Add the shortcode above the slide’s content, below the ---.

---

{{< slide class="hello" >}}

## Hello, world!

---

Custom slide 1

Did you notice? This slide has a fast zoom transition.

---

{{< slide transition="zoom" transition-speed="fast" >}}

## Custom slide 1

---

Custom slide 2

This slide has a different background color.

---

{{< slide background-color="#FF4081" >}}

## Custom slide 2

---

Custom slide 3

This slide has a background image.

---

{{< slide background-image="/images/alex-litvin-790876-unsplash.jpg" >}}

---

(credit Alex Litvin)

💡 Tip: Setting a slide’s id attribute makes it easy to link to from other parts of the presentation.

---

{{< slide id="custom-slide" >}}

## Custom slide

---
[Try the link](#custom-slide)


Try the link

Slide attribute possibilities from the Reveal.js docs:

  • autoslide
  • state
  • background
  • background-color
  • background-image
  • background-size
  • background-position
  • background-repeat
  • background-video
  • background-video-loop
  • background-video-muted
  • background-interactive
  • background-iframe
  • background-transition
  • transition (can have different in and out transitions)
  • transition-speed
  • notes (can also use the note shortcode)
  • timing

Slide templates

Store sets of common slide attributes in front matter variables and apply them to slides with the template attribute.


navigate down to learn more
đŸ”Ŋ

Create templates in config.toml, _index.md or the current page’s front matter. Put them under the templates key with a meaningful name:

[reveal_hugo.templates.hotpink]
class = "hotpink"
background = "#FF4081"

Apply the template using the template attribute of the slide shortcode:

{{< slide template="hotpink" >}}

# I'm a hot pink slide!

If a template exists in multiple configurations, it’s properties will be merged. If a property is declared multiple times, the order of precedence is:

  • page
  • section (_index.md)
  • site (config.toml)

Reusable slides

Store markdown in a data template and reuse it in multiple sections or presentations.


navigate down to learn more
đŸ”Ŋ

Add a example key to data/home.toml:

example = "I'm a slide"


Set the content attribute to “home.example”:

---

{{< slide content="home.example" >}}

---

💡 Each data template entry can contain one or more slides, separated by --- with newlines.

💡 All other slide shortcode attributes (background, transition, etc.) can be used and will be applied to each slide in the data template entry.

Slide-specific CSS

Add more variety to your presentation by applying slide-specific CSS.


navigate down to learn more
đŸ”Ŋ

First, use the slide shortcode to give the slide a class:

---

{{< slide class="side-by-side" >}}

# 📈

# 📊

---

Next, use a layout extension partial like reveal-hugo/head.html to add CSS selectors:

<style>
.reveal section.side-by-side h1 {
  position: absolute;
}
.reveal section.side-by-side h1:first-of-type {
  left: 25%;
}
.reveal section.side-by-side h1:nth-of-type(2) {
  right: 25%;
}
</style>

📈

📊

Note

Add speaker notes to your presentation with the note shortcode.

{{% note %}}

Type 's' to see this slide's speaker notes.

{{% /note %}}

Write slides in HTML

Use a section tag with a data-noprocess attribute to avoid any processing by reveal-hugo.

<section data-noprocess>
  <h1>Hello world!</h1>
<section>
💡 This is useful if you can't get Markdown to output exactly what you want.

Resources

Code and docs

External resources

Designed to…

🙏

Contribute by opening issues and pull requests.

Thanks!

↩ī¸

Start over