Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated front page contains one <h1> for each post, I wish they were <h2> #3708

Open
tartley opened this issue Aug 23, 2023 · 4 comments
Open

Comments

@tartley
Copy link
Contributor

tartley commented Aug 23, 2023

Environment

Python Version: 3.10.12
Nikola Version: 8.2.4
Operating System: Pop!_OS 22.04 (derived from Ubuntu 22.04)

Description

My generated front page has several <h1> tags in it, one for each included post. I want them to be <h2> tags instead.

Only using a single <h1> is recommended as a best practice (e.g. here in Mozilla developer network). In particular, I'm trying to register my Nikola site with Bing webmaster tools, so that it will get indexed and appear in search results. To be indexed, a page must only have at most one <h1> tag. So I can't get my front page indexed.

I tried editing my conf.py, uncommenting either PANDOC_OPTIONS = ['--base-header-level=2'], or DEMOTE_HEADERS = 1, but this has not had any effect.

(Incidentally, grepping the code for 'DEMOTE_HEADERS' only finds this instance. Is this option currently used?)

@tartley tartley added the bug label Aug 23, 2023
@sukiletxe
Copy link
Contributor

Iirc both options are only used in headings of the bodies of posts.

I do agree with this sentiment, but this creates another problem, what about posts with subheadings? How do we accomodate both "headings should be hierarchical" and "only one h1 per page"?

@tartley
Copy link
Contributor Author

tartley commented Aug 23, 2023

A fair question.

I had imagined, when I saw the conf.py options to demote headings, that they would demote all headings by the same amount. Hence h2 would become h3, and the max (h7?) would become a standalone para of regular text.

Presumably though, this question is independent of the issue I'm raising. The demotion of sub-headers is "handle demotion correctly", and needs to be done right on individual posts too, while this issue is "apply the demotion on the front page as well as individual posts."

@Kwpolska
Copy link
Member

This single-<h1> rule is a bit nonsensical IMO, and Bing should not reject webpages for things like this; they certainly didn’t mind indexing Nikola’s blog.

If you want to follow this rule, you would need to change your templates so that there is a <h1> associated with the site title (there isn’t in bootstrap themes, and a <h1> in the menu bar would be weird and hard to style — should our pages have no <h1>s at all if we apply the rule?), and post/page titles are <h2>. Afterwards, setting DEMOTE_HEADERS = 2 should convert first-level headers in input to <h3> and the outlines would match the standards.

@tartley
Copy link
Contributor Author

tartley commented Aug 23, 2023

Thanks for the input. FWIW I mis-spoke earlier - Bing webmaster tools produces an error about the multiple h1 tags, but once I cleared up other errors, it will now index the page. So this doesn't block indexing after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants