Styling tables with Hugo
Markdown sometimes isn’t enough
- tags
- bootstrap
- hugo
Contents
Markdown is a nice format to write it, but sometimes you need to add HTML classes directly to the output to make it look how you want. Here’s a way to do that using hugo shortcodes.
Create a table shortcode
Put this in /layouts/shortcodes/table.html:
| |
Create a table
Like this:
| |
Which should render like so:
| Header 1 | Header 2 | Header 3 |
|---|---|---|
| Item 1 | Item 2 | Item 3 |
| Item 1a | Item 2a | Item 3a |
Wrap it in shortcodes
| {{<table “table table-striped table-bordered”>}} | ||
|---|---|---|
| Item 1 | Item 2 | Item 3 |
| Item 1a | Item 2a | Item 3a |
| {{</table>}} |
Which should render:
| Header 1 | Header 2 | Header 3 |
|---|---|---|
| Item 1 | Item 2 | Item 3 |
| Item 1a | Item 2a | Item 3a |
References
Previously
Next