themen-hugo-35c3-reveal/README.md

181 lines
5.7 KiB
Markdown
Raw Normal View History

2018-04-26 17:25:43 -05:00
# reveal-hugo
2018-04-28 01:31:21 -05:00
A Hugo theme for [Reveal.js](https://revealjs.com/) that allows you to have multiple slides per markdown file. With it, you can turn any of your Hugo content into a presentation by adding `Reveal` to its output formats.
2018-04-26 17:25:43 -05:00
![screenshot of reveal-hugo](/images/reveal-hugo.png)
2018-04-26 18:12:22 -05:00
The motivation behind creating this theme is pretty simple - I didn't want to have to manage one markdown file for every slide, which would add the overhead of coming up with a file name, setting a `weight` param in the front matter to keep it in order, etc, all for just a few lines of text. Instead, I like to organize groups of slides into a smaller number of markdown files, each representing a section of the presentation.
### Example
2018-04-27 00:37:10 -05:00
Using reveal-hugo, a three-slide (or n-slide) presentation can be created with just one markdown file, like so:
2018-04-26 18:12:22 -05:00
```markdown
# English
Hello.
---
# Français
Salu.
---
# Espagñol
Hola.
```
The only requirement is to demarcate slides with `---` surrounded by newlines.
2018-04-28 01:31:21 -05:00
## Demo
2018-04-26 18:12:22 -05:00
2018-04-28 01:31:21 -05:00
Visit [https://dzello.com/reveal-hugo/](https://dzello.com/reveal-hugo/) to see a presentation created with this theme. You can also check out this exact repository [deployed to Netlify](https://reveal-hugo.netlify.com/).
2018-04-26 18:12:22 -05:00
2018-04-28 01:31:21 -05:00
## Usage
2018-04-26 18:12:22 -05:00
2018-04-28 01:31:21 -05:00
### Create your first presentation
To start, [install Hugo](https://gohugo.io/) and create a new Hugo site:
2018-04-27 01:20:05 -05:00
```shell
$ hugo new site my-presentation
```
2018-04-27 01:37:02 -05:00
Change into the directory of the new site:
2018-04-27 01:20:05 -05:00
```shell
2018-04-27 01:37:02 -05:00
$ cd my-presentation
2018-04-27 01:20:05 -05:00
```
2018-04-28 01:31:21 -05:00
Clone the reveal-hugo theme into the themes directory:
2018-04-27 01:20:05 -05:00
```shell
2018-04-27 01:37:02 -05:00
$ git clone git@github.com:dzello/reveal-hugo.git themes/reveal-hugo
2018-04-27 01:20:05 -05:00
```
2018-04-28 01:31:21 -05:00
Open `config.toml` and add the following contents:
2018-04-27 01:20:05 -05:00
```toml
2018-04-28 01:31:21 -05:00
theme = "reveal-hugo"
[outputFormats.Reveal]
baseName = "index"
mediaType = "text/html"
isHTML = true
2018-04-27 01:20:05 -05:00
```
2018-04-28 01:31:21 -05:00
This tells Hugo to use the reveal-hugo theme and it registers a new output format called "Reveal".
2018-04-28 01:31:21 -05:00
Next, create a file in `content/_index.md` and add the following:
```markdown
2018-04-27 01:20:05 -05:00
+++
title = "My presentation"
outputs = ["Reveal"]
2018-04-27 01:20:05 -05:00
+++
# Hello world!
This is my first slide.
```
Back on the command line, run:
```shell
2018-04-28 01:31:21 -05:00
$ hugo server
2018-04-27 01:20:05 -05:00
```
2018-04-28 01:31:21 -05:00
Navigate to [http://localhost:1313/](http://localhost:1313/) and you should see your presentation.
2018-04-27 01:20:05 -05:00
2018-04-27 01:28:29 -05:00
![New site with reveal-hugo](/images/reveal-hugo-hello-world.png)
2018-04-28 01:31:21 -05:00
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.
2018-04-27 01:37:02 -05:00
```markdown
2018-04-28 01:31:21 -05:00
# Hello world!
This is my first slide.
2018-04-27 01:37:02 -05:00
---
# Hello Mars!
2018-04-28 01:31:21 -05:00
This is my second slide.
2018-04-27 01:37:02 -05:00
```
2018-04-28 01:31:21 -05:00
### Create a root presentation
2018-04-27 01:20:05 -05:00
2018-04-28 01:31:21 -05:00
To create a presentation that lives at the site root, create a `content/_index.md` file and specify that the `Reveal` output format should be used in the front matter:
2018-04-26 18:12:22 -05:00
```toml
2018-04-28 01:31:21 -05:00
outputs = ["Reveal"]
2018-04-26 18:12:22 -05:00
```
2018-04-28 01:31:21 -05:00
Content for this presentation can come from `_index.md`, files in the `home` directory, or any content file whose type is set to `home` in the front matter.
Use the `weight` param in the front matter to specify the order that content from these files should appear in the presentation, knowing that content from `_index.md` will always come first.
2018-04-26 18:12:22 -05:00
```toml
weight = 20
```
2018-04-28 01:31:21 -05:00
### Create a section presentation
2018-04-26 18:43:52 -05:00
To create a presentation for the content of any section of your Hugo site, just add `Reveal` to its list of `outputFormats` in the front matter of `section/_index.md`:
2018-04-26 18:43:52 -05:00
```toml
outputs = ["Reveal"]
```
Section presentations will include content from each file in that section. Again, use the `weight` param to order the sections, knowing that any content in `_index.md` will come first.
Presentations can use a different Reveal.js theme by specifying the `reveal_theme` parameter in the front matter of the section's `_index.md` file.
2018-04-27 00:50:08 -05:00
```toml
2018-04-27 01:23:13 -05:00
reveal_theme = "moon"
2018-04-27 00:50:08 -05:00
```
2018-04-28 01:35:27 -05:00
### Add a Reveal.js presentation to an existing Hugo site
If your Hugo site already has a theme but you'd like to create a presentation from some of its content, that's very easy. First, manually copy a few files out of this theme into a few of your site's directories:
```shell
$ cd my-hugo-site
$ git clone git@github.com:dzello/reveal-hugo.git themes/reveal-hugo
$ cp -r themes/reveal-hugo/static/reveal static/reveal
$ cp themes/reveal-hugo/layouts/_default/*.reveal.html layouts/_default
$ cp themes/reveal-hugo/layouts/shortcodes/* layouts/shortcodes
$ cp themes/reveal-hugo/layouts/partials/* layouts/partials
```
Next, add the Reveal output format to your site's `config.toml` file
```toml
[outputFormats.Reveal]
baseName = "index"
mediaType = "text/html"
isHTML = true
```
2018-04-28 01:35:27 -05:00
Now you can add `outputs = ["Reveal"]` to the front matter of any section's `_index.md` file and that section's content will be combined into a presentation and written to `index.html`. If you already have a `index.html` page for that section, just change the `baseName` above to `reveal` and the presentation will be placed in a `reveal.html` file instead.
2018-04-28 01:35:27 -05:00
Note: If you specify `outputs = ["Reveal"]` for a single content file, you can prevent anything being generated for that file. This is handy if you other default layouts that would have created a regular HTML file from it. Only the list file is required for the presentation.
2018-04-28 01:35:27 -05:00
## Features
### Fragments
2018-04-26 18:12:22 -05:00
Fragments are a Reveal.js concept that lets you introduce content into each slide incrementally. Borrowing the idea from [hugo-theme-revealjs](https://github.com/RealOrangeOne/hugo-theme-revealjs) (thanks!), you can use a `fragment` shortcode to accomplish this in reveal-hugo in the same way.
2018-04-26 18:12:22 -05:00
```markdown
# Let's count to three...
{{% fragment %}} One {{% /fragment %}}
{{% fragment %}} Two {{% /fragment %}}
{{% fragment %}} Three {{% /fragment %}}
```
2018-04-28 01:35:27 -05:00
### Configuration params
2018-04-26 18:12:22 -05:00
These settings go in `config.toml`:
2018-04-26 18:12:22 -05:00
- `params.reveal_theme`: The Reveal.js theme used, defaults to "black"