Hugo: Can Hugo render a table without a header?

Created on 2 Nov 2016  Â·  5Comments  Â·  Source: gohugoio/hugo

According to introduction page, Hugo uses native Markdown support. I know that by default Markdown requires each table to have a header, but sometimes it is very useful to create a table without it:

| | |
---|---
x|5
y|3

| | |
---|---
x|5
y|3

As you can see in this example, the header seems to be rather useless. Of course, I could put variable name and variable value there, but that does not seems to be necessary, since the table is self explainatory.

I tried to create a table without a header in Hugo (I removed the first line: | | |) but the Markdown file was not parsed correctly (I got —|— x|5 y|3 as a result). When I left the first line, I got a table with an empty header (and it looked ugly when I added a border around the cells).

I know that what I'm asking for is against the standard (at least I think it is) but some Markdown processors (like kramdown) don't have such limitations (a table without a header can be easily rendered). I also know that Markdown let's you add HTML code, but that would be a very ugly solution.

Is there a chance that Hugo will be able to render a headerless table using a Markdown file? I would rather not resort to using Jekyll :)

The version I used was:

v0.16-DEV BuildDate: 2016-02-06T18:14:17+01:00

Most helpful comment

And of course this is the first result in google, unceremoniously closed and without an answer.

For anyone else arriving here from google, the docs and discuss site provide no answer so I assume you have to use messy workarounds or switch to a generator that supports something like kramdown.

All 5 comments

Please use http://discuss.gohugo.io/ for questions/troubleshooting. Also see Hugo Documentation.

And of course this is the first result in google, unceremoniously closed and without an answer.

For anyone else arriving here from google, the docs and discuss site provide no answer so I assume you have to use messy workarounds or switch to a generator that supports something like kramdown.

@Brendan-McCoy - best to go to the discourse site and pose the actual question and point fellows users to a repo if you’re not finding what you’re looking for in terms of searching questions others have already asked...

@brendan-McCoy

You can set the color of the header to match the background and use empty space in the header.

```

| | |
|-----|-----------|
|text||text|

```

This one is for my fellow developer comrades who got here from Google.

The easiest option I ended up using:

table tr th:empty {
  display: none;
}
  • Completely hides the empty header cells not used.
  • Preserves table header cells that actually have content.
  • Maintains spacing without needing to adjust anything around it.
  • You don't need to add/change any .md markdown.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

vielmetti picture vielmetti  Â·  3Comments

arikroc picture arikroc  Â·  3Comments

crash-dive picture crash-dive  Â·  3Comments

tjamet picture tjamet  Â·  3Comments

moorereason picture moorereason  Â·  3Comments