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

Search-Index and Sitemap not generated after Theme update #743

Closed
andi-blafasl opened this issue Dec 1, 2023 · 7 comments
Closed

Search-Index and Sitemap not generated after Theme update #743

andi-blafasl opened this issue Dec 1, 2023 · 7 comments
Labels
update A change in behaviour after update

Comments

@andi-blafasl
Copy link

Hey Folks,

just updating the theme on our project "BITS Training" form version 5.3 to 5.23. Fixed all error, warning and deprecation messages during hugo build but can't get search to work. It was working perfect with the old "JSON" Based search before.

I checked the index.search.js and it is quite empty. It seams only the more section content is indexed. These are the sites that where moved due to the changes in Theme version 5.9

The same thing is happening with the sitemap.xml. It was working with Theme 5.3 and now only the more section content is listed in the sitemap.xml 🤷‍♂️

Maybe someone can check out the repo and give me a hint what's going wrong with our content?

Many thanks 😊

@McShelby
Copy link
Owner

McShelby commented Dec 1, 2023

I'll take a look into it... stay tuned

@McShelby
Copy link
Owner

McShelby commented Dec 1, 2023

This seems to be race condition. If I run hugo server initially the index is broken. If I change the index template and cause a regeneration, the index is fine.

Interestingly, my own page never behaved this way...

...still thinking how to avoid this...

@McShelby
Copy link
Owner

McShelby commented Dec 1, 2023

Ok, got it. Although I still don't know why this race condition happens.

The main reason is, that pages with empty title are treated as hidden. This was always the case but over the theme's version history additional checks got added where they were missing.

In your case your content/_index.de.md does have an empty title and therefore the page itself and all descendends are treated as hidden. This causes them to be excluded from the search as long as you don't set disableSearchHiddenPages = false (which I don't recommend here)

To solve it, exchange your title to this:

title: " "

@McShelby McShelby added the update A change in behaviour after update label Dec 1, 2023
@andi-blafasl
Copy link
Author

Wow! Thank you so much for this quick find. The empty Title in the top most _index.de.md was changed during the update because of the new archtype=home Template that is used. We have a H1 with a parameter in the content and this was the easiest way to get the same look. Think this was a bit too quick and dirty 😉 Will try to find a better solution with a real title, but your idea with a space is a nice workaround and kept in mind.

But it's interesting why this accidental hiding of the pages doesn't affect the menu generation?

@McShelby
Copy link
Owner

McShelby commented Dec 1, 2023

But it's interesting why this accidental hiding of the pages doesn't affect the menu generation?

He he, Full roundtrip here: #134 (comment)

If you visit a hidden page, it is always revealed in your menu. Because the hidden option is not inherited by its descendends, they will all be shown as well.

@McShelby McShelby closed this as completed Dec 1, 2023
@andi-blafasl
Copy link
Author

🙄 lol 🤣

andi-blafasl added a commit to BITS-Training/BITS-hugo that referenced this issue Dec 1, 2023
Ein leerer Titel versteckt die Seite und alle Unterseiten.
Macht man das in der Homepage, dann sind alle Seiten versteckt und
werden damit weder in der Suche noch in der Sitemap eingebunden.

see also: McShelby/hugo-theme-relearn#743 (comment)
@McShelby
Copy link
Owner

McShelby commented Dec 1, 2023

I soon have a more elegant solution: #744

The basic idea is, to override the new heading.html partial with the following:

{{ if not .IsHome }}<h1 id="{{ .Title | plainify | anchorize }}">{{ .Title }}</h1>{{ end }}

By that, you could revert content/_index.de.md to the version before the update and just delete the archetype option.

andi-blafasl added a commit to BITS-Training/BITS-hugo that referenced this issue Dec 2, 2023
Ein leerer Titel versteckt die Seite und alle Unterseiten.
Macht man das in der Homepage, dann sind alle Seiten versteckt und
werden damit weder in der Suche noch in der Sitemap eingebunden.

see also: McShelby/hugo-theme-relearn#743 (comment)
andi-blafasl added a commit to BITS-Training/BITS-hugo that referenced this issue Dec 5, 2023
Ein leerer Titel versteckt die Seite und alle Unterseiten.
Macht man das in der Homepage, dann sind alle Seiten versteckt und
werden damit weder in der Suche noch in der Sitemap eingebunden.

see also: McShelby/hugo-theme-relearn#743 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
update A change in behaviour after update
Projects
None yet
Development

No branches or pull requests

2 participants