Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

reveal-hugo

> 开发工具
Open source

️ Create rich HTML-based presentations with Hugo and Reveal.js

742 stars0 likes2 views
WebsiteGitHub

About

️ Create rich HTML-based presentations with Hugo and Reveal.js

reveal-hugo

A Hugo theme for Reveal.js that makes authoring and customization a breeze. With it, you can turn any properly-formatted Hugo content into a HTML presentation.

⚠️ The latest version of this theme requires hugo version >= v0.93.0. If you need compatibility with an earlier version, try a previous release.

Example

Using reveal-hugo, presentations with multiple slides can be created with just one markdown file, like so:

markdown
+++
title = "How to say hello"
+++

# English
Hello.

---

# Français
Salut.

---

# Español
Hola.

Just use --- surrounded by blank lines to split content into different slides.

Documentation

Visit reveal-hugo.dzello.com to see a presentation created with this theme and learn about all of the different functionality available to you.

For a full-length blog post about reveal-hugo, checkout Harness the Power of Static Site Generators to Create Presentations on the Forestry.io blog.

Demos

Jump to the exampleSite folder in this repository to see the source code for the above presentation and several more. Here are links to those presentations live:

  • logo-example - Shows how to add a logo to your presentation
  • custom-theme-example - Uses Hugo pipes to compile and use a custom Reveal.js SCSS theme (recommended!)
  • section-example - Very basic example that shows how to create a presentation for a Hugo section
  • plugin-example - Shows how to add additional Reveal.js plugins to your presentation, for example an image gallery
  • template-example - An example of using the slide shortcode with powerful templates
  • bundle-example - An example of creating a presentation from one or more markdown files in a leaf bundle
  • hugo-hl-example - An example of using Hugo's compile-time syntax highlighter
  • highlightjs-linenumbers-example - An example of using the multiline and multi-step capabilities of highlight.js
  • blank Reveal-Hugo template - A templated skeleton site to get started quickly

Starter repository

If you want to start creating a presentation right away, clone the programming-quotes repository and start hacking.

Tutorial: Create your first presentation

You should be able to complete this section with no prior knowledge of Hugo or Reveal.js. At the end, you'll have a working presentation with instant reloading.

Create a hugo skeleton site

To start, install Hugo and create a new Hugo site:

bash
hugo new site my-presentation

Change into the directory of the new site:

bash
cd my-presentation

Initialize a git repository:

bash
git init

Get the reveal-hugo theme

Method 1 (recommended): use theme as hugo module

Turn your new skeleton site into a hugo module by issuing this command from site root:

bash
hugo mod init github.com/me/my-presentation
  • Declare the reveal-hugo theme module as a dependency of your site:
hugo mod get github.com/joshed-io/reveal-hugo

Open hugo.toml and add the following line:

toml
theme = ["github.com/joshed-io/reveal-hugo"]

Method 2 (traditional): use theme as git submodule

Add the reveal-hugo theme as a submodule in the themes directory:

bash
git submodule add [email protected]:joshed-io/reveal-hugo.git themes/reveal-hugo

Open hugo.toml and add the following line:

toml
theme = ["reveal-hugo"]

Configure your presentation

Add some more contents to your hugo.toml:

toml
[markup.goldmark.renderer]
unsafe = true

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

This tells Hugo to use the reveal-hugo theme and it registers a new output format called "Reveal".

Next, create a file in content/_index.md and add the following:

markdown
+++
title = "My presentation"
outputs = ["Reveal"]
+++

# Hello world!

This is my first slide.

Back on the command line, run:

bash
$ hugo server

Navigate to http://localhost:1313/ and you should see your presentation.

To add more slides, just add content to _index.md or create new markdown files in content/home. Remember that each slide must be separated by --- with blank lines above and below.

markdown
# Hello world!

This is my first slide.

---

# Hello Mars!

This is my second slide.

Cloning an existing repository (method 2 only)

If you have an existing repository that was setup with the above steps, you have to pull in the theme submodule after cloning your repository using the following command:

bash
git submodule update --init

Theme update (method 1 only)

When making use of reveal-hugo theme as hugo module, updating your theme is really easy:

At the command prompt, change to the root directory of your existing site.

cd /path/to/my-presentation

Then invoke hugo's module get subcommand with the update flag -u:

hugo mod get -u github.com/joshed-io/reveal-hugo

Hugo will automatically pull in the latest theme version. That's it, your update is done!

Usage

The Usage guide is contained in the example presentation that lives in this repository in the exampleSite directory. You can access a live version at reveal-hugo.dzello.com.

Root vs. section presentations

Here's what the folder structure would look like with one root presentation and one section presentation.

- content
  - home # special section for appending to root presentation
    - body.md # appends to the root presentation
    - conclusion.md # appends to the root presentation
  - _index.md # beginning of the root presentation
  - ted-talk
    - _index.md # beginning of the ted talk presentation
    - body.md # appends to the ted talk presentation
    - conclusion.md # appends to the ted talk presentation

This will create two presentations, one at / and one at /ted-talk/. The order that slides are appended to each can be controlled by the weight parameter specified in each file's front matter. The slides in _index.md will always come first, though you don't have to put any slides in there if you want to.

Shortcodes

reveal-hugo comes with a variety of shortcodes that help you take advantage of some very useful Reveal.js features.

fragment shortcode

Wrap any content in the fragment shortcode and it will appear incrementally. Great for bulleted lists where you want one bullet point at a a time to appear.

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

frag shortcode

Like fragment but more terse - content is placed inline in a self-closing shortcode.

markdown
- {{}}
- {{}}
- {{}}

slide shortcode

The slide shortcode lets you set custom HTML and Reveal.js attributes for each slide - things like id, class, transition, background just to name a few. The names are the same as Reveal.js but without the 'data-' prefix.

Add the shortcode above the slide content, below the --- separator. Do not place content inside of the shortcode.

markdown
---

{{}}

# Hello, world!

---

Here's a list of documented slide attributes from the Reveal.js docs:

  • autoslide
  • state
  • background
  • background-color
  • background-image
  • background-size
  • background-position
  • background-repeat
  • background-opacity (Opacity is on a 0-1 scale, by decimal. 0=transparent, 1=opaque.)
  • 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

Additional data attributes

Check MDN for information about how these attributes work.

  • data-background-image - URL of the image to show. GIFs restart when the slide opens.
  • data-background-size
  • data-background-position
  • data-background-repeat
  • data-background-opacity

You can also pass through your own, a data- prefix will be added automatically to each one (except for id and class).

section shortcode

To create groups of slides that can be navigated vertically, surround your markdown with the section shortcode.

markdown
{{% section %}}

# Vertical slide 1

---

# Vertical slide 2

{{% /section %}}

note shortcode

Add speaker notes for each slide with the note shortcode.

markdown
{{% note %}}
Don't forget to thank the audience.
{{% /note %}}
  • Tip: you can also add notes by adding a note attribute to the slide shortcode.*

markdown shortcode

Markdown surrounded by the markdown shortcode will not be rendered by Hugo but by Reveal.js itself. This is useful if you want to use some native Reveal.js markdown syntax that isn't supported by reveal-hugo.

markdown
{{% markdown %}}
# I'm rendered...
...by Reveal.js
{{% /markdown %}}

Maths and equations (via MathJax)

Option 1: math code block

You can author your equation inside a math code block:

markdown
```math
\tag*{(1)} P(E) = {n \choose k} p^k (1-p)^{n-k}
```

Use of the code block will automatically activate needed MathJax script for equation display.

If you want to use inline equations (like $E=mc^2$) wrap your math content in two single-$:

markdown
Albert Einstein's famous formula: $E=mc^2$

If you want to use inline equations and no math code block for auto activation is present in your slides, you need to manually enable MathJax by setting the parameter math to true in your page frontmatter.

Option 2: math shortcode

Alternatively, you can author your equation inside a math shortcode:

markdown
{{}}
\tag*{(1)} \frac{n!}{k!(n-k)!} = \binom{n}{k}
{{}}

Use of the shortcode will automatically activate needed MathJax script for equation display.

For inline equations (like $E=mc^2$) use the self closing form of the math shortcode:

markdown
Albert Einstein's famous formula: {{}}

For the sake of brevity, the inline content can be given as unnamed first shortcode parameter, as in the code fragment above. In a more concise form, the math content can also be assigned to a named shortcode parameter inline: {{}}.

HTML slides

If you need to create fancier HTML for a slide than you can do with markdown, just add data-noprocess to the <section> element.

xml

  
Hello, world!

Reusable slides and sections

Sometimes you need to reuse a slide in the same presentation or across different presentations. reveal-hugo makes use of Hugo data templates to make both cases easy.

To create reusable slides, create a TOML (or JSON or YAML) file in your site's data directory. Give it a name that reflects its content or just slides.toml. In that file, add a key for each reusable slide. The name should reflect the slide's content and the value should be the slide's markdown.

toml
thankyou = '''

# Thank you!

Any questions?

'''
  • Tip: TOML's multiline string syntax comes in handy here, note the '''

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScripthugopresentationreveal-jsslides

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具