Autonumbering of headings
I think adding
body {
counter-reset: h2counter;
}
article h1 {
counter-reset: h2counter;
}
article h2::before {
content: counter(h2counter) ".";
counter-increment: h2counter;
counter-reset: h3counter;
}
article h3::before {
content: counter(h2counter) "." counter(h3counter) ".";
counter-increment: h3counter;
}
to hugo-coder/assets/scss/_base.scss should give sectioning like
Title of the article
1. heading h2 made with one # in md or * in org
1.1.
1.2.
2. heading h2 made with one # in md or * in org
2.1
but what it gives me is:
Title of the article
1. heading h2 made with one # in md or * in org
0.1.
0.2.
1. heading h2 made with one # in md or * in org
0.1
I do not know if that is indeed a bug. But I would also like to suggest the implementation of an option to be set in the frontmatter of each article to decide if that article should have section numbers or not.
I'd like to add my thanks for this excellent theme. Besides I tested adding that code to the analogous file to another project using Eureka theme and the expected result was obtained.
I tried following this post, but things do not work out well following it either. (There is some content in the comments section.) https://codingnconcepts.com/hugo/auto-number-headings-hugo/
I don't have an answer to this problem. I will try testing your changes later.
Edit: this was only an apparent fix.
I managed to obtain the correct numbering, but I would not be able to explain why it works. In the file assets/scss/_base.scss, I've head to add to the first body { } the line:
counter-reset: h1 h2 h3 h4 h5 h6;
Then, to h1 { } the line
counter-reset: h2;
and analogously with hn{ } to each h(n+1) until n=5. Having done those modifications, the snippets
article h2::before {
content: counter(h2counter) ".";
counter-increment: h2counter;
counter-reset: h3counter;
}
have the desired effect.
I decided to do that observing this file https://github.com/rougier/homepage/blob/master/python-opengl/book.css
It was only an apparent fix, probably due to havin created another hugo site for testing. When the numbering bug takes effect, going to the another site project and running hugo server, canceling and then running back the first site, makes the numbering correct again.