-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Idea: ".SecondSection" #860
Comments
It's possible, but there might be some edge case that needs to be considered (for example, how to determine if the documents belong to first/second section). I'm not very interested in this, but PR is welcome. You can achieve this easily by separating books into the first sections. |
OK, just think of a simple method, to test it:
|
I tried, feat-root-section, I didn't notice any change of functionality I am trying this now (planned to try this week): {{/* layouts/partials/getSecondLevelSection.html */}}
{{- /* Returns the second-level section for the current page */ -}}
{{- define "getSecondLevelSection" -}}
{{- $currentPage := . -}}
{{- $ancestors := .Ancestors -}}
{{- $secondLevel := nil -}}
{{- if ge (len $ancestors) 2 }}
{{- /* If there are at least two ancestors, get the second-level ancestor */ -}}
{{- $secondLevel = index $ancestors (sub (len $ancestors) 2) -}}
{{- else if eq (len $ancestors) 1 }}
{{- /* If there's only one ancestor, the parent is the second-level section */ -}}
{{- $secondLevel = $currentPage.Parent -}}
{{- else }}
{{- /* If no ancestors, the current page is the top-level */ -}}
{{- $secondLevel = $currentPage -}}
{{- end -}}
{{- $secondLevel -}}
{{- end -}}
Why do I need that? Suppose website has few books, and each book is around 200-400 pages; I may even have bigger books; having 400 "href" elements per webpage will make it SEO-unfriendly, load time on mobile devices will be high, although no issues with Web browsers (for comparison, typical Amazon website page has around 400 "href" elements). I have 800-pages book project, split in few parts... thanks, |
This is solution suggested by AI ;)
|
Maybe this is what I need, testing now: |
Hmm, please describe it in detail? I've tested it myself before I pushed that branch.
Is there any related SEO advice from the official website? Such as Google itself. BTW, I didn't follow the code you provided. If the number of links is sort of matter, then we need to reduce it in some way or just hide the navigation. |
There are no such "official" advice. However, basic ranking algorithm for text is TF/IDF (term frequency / inverse document frequency), so that 400 links with non-related text may devalue main textual content of the page, etc.; Google algo may find it "keywords stuffing" and so on; yes, nice to have This page has 795 "href" in it: https://securitiesexamsmastery.ca/14/ And all child pages have the same 795. https://pagespeed.web.dev/analysis/https-securitiesexamsmastery-ca-14/npj7zbx3e3?form_factor=mobile |
Quoting user comment from 2019 here, "Google used to recommend that any page have no more than 100 links per page. However, they removed the "100 links per page" from the webmaster guidelines some time ago. Matt Cutts released a video where he says that the limits for page size and number of links per page are much higher than they used to be. I've personally worked on a website with 250-400 links on every page. That site did very well in search engines." |
Also, I'd like to mention that previous version of the same book https://securitiesexamsmastery.ca/14/ had 3 and even 4 levels of navigation, with same amount of pages navigation was much slower in Chrome browser, I believe because of sophisticated DOM. Now, it is only "chapter/section", two levels of navigation, and it feels 10x faster (with even more pages) |
My fault; https://securitiesexamsmastery.ca/14/ "root" page is |
I'll try again; maybe I did something incorrect. |
This webpage, for example, is No.1 in search results (in my Canadian area), https://www.google.com/search?q=canary+deployments+clojure&rlz=1C5CHFA_enCA950CA950&oq=canary+deployments+clojure&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRigAdIBBzI2MWowajeoAgCwAgA&sourceid=chrome&ie=UTF-8 "canary deployments clojure" / but note, "clojure" is rarely searchable... 300x less popular than JavaScript ;) https://clojurepatterns.com/9/8/2/ It has 588 "href" elements. But some other pages have around 1100+ "href", https://clojurepatterns.com/10/9/23/ for example. I think Google is smart enough. Also, it is two-level-hierarchy with navigation. I am going to make repo public for this site too. |
I tried again |
ok, it looks like installed correct module, |
I think I confused everyone... I have this layout currently:
Homepage will show book1, book2, book3. When I click "book1", it will show only content of "book1" (which is 2nd level from "root"). And what I suggested is to have functionality for 3rd level. Maybe that's why I cannot test "book1/_index.md" has `type: docs" in it. See https://github.com/MasteryEducation/SecuritiesExamsMastery.ca/tree/main/content for example, I have two "books" on it, https://securitiesexamsmastery.ca/ |
I forgot that I override Thank you @razonyang |
@FuadEfendi So that branch is working right? If so, I'll merge it later. |
I am wondering if it is possible to implement something like ".SecondSection" (instead of ".FirstSection"), for left-side navigation:
docs/layouts/partials/hb/modules/docs/nav.html
Line 1 in 033bfdd
My layout is quite large :
The goal is, when I click
expert-books -> book3
on top level menu, to open page athttp://localhost:1313/expert-books/book3
, it should show chapters frombook3
. But right now it shows book1, book2, book3, because of.FirstSection
returnsexpert-books
content. Maybe it is easier to create such function as Hugo-core?I am not sure how hard is it; just sharing idea, researching... thanks,
The text was updated successfully, but these errors were encountered: