-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Use index pages + automatic navigation arrows #36
Conversation
@lierdakil Thank you for your PR and first (big!) contribution 😃 Sorry, I did not see this PR before. I will look into it ASAP. |
Gods above. I noticed a typo.
This should be "navigation arrows". I have no idea how arrows became errors.... Probably mobile autocorrection. |
I got the following error by testing your PR with hugo-learn-doc:
As an testing example, feel free to fork https://github.com/matcornic/hugo-learn-doc . Please rebase before testing with Hugo 0.20, i just fixed another error (same as https://discuss.gohugo.io/t/v0-20-error-error-calling-isset-unsupported-type-invalid/5668). Thanks again 👍 |
Okay, I believe this particular problem is fixed now. Apparently, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to work great after my fix 👍
layouts/partials/footer.html
Outdated
{{if eq $element.UniqueID $uniqueid }} | ||
{{ if not (isset $.Params "prev") }} | ||
{{ with index $allpages (sub $index 1) }} | ||
<a class="nav nav-prev" href="{{ $.Site.BaseURL }}{{ .URL }}"> <i class="fa fa-chevron-left"></i></a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it again, and I have problems when using baseurl
for arrow links. For example, I use "https://matcornic.github.io/hugo-learn-doc" as baseurl
in my config.toml
. So when I hugo serve
, the server is starting at http://localhost:1313/hugo-learn-doc/
But, when I set autoNav=true
, href
of arrows links are not the right ones. For example:
- Current page: http://localhost:1313/hugo-learn-doc/basics/
- Arrow link expected: http://localhost:1313/hugo-learn-doc/basics/what-is-this-hugo-theme/
- Actual arrow link: http://localhost:1313/hugo-learn-doc//hugo-learn-doc/basics/what-is-this-hugo-theme/
It seems we have already the $.Site.BaseURL
in .URL
. I removed it locally and it seems to work (when I set baseurl
or not)
prev
/next
parameters overriding have to keep $.Site.BaseURL
though.
Since it's already included in `Page.URL`
Okay, that's kinda obvious in hindsight. Fixed. I also changed |
Got 2 more problems:
Moreover, could you change |
* fix menu ordering when mixing chapters and non-chapters * allow for `chapter` type override in `_index` pages * fix breadcrumbs * fix some crashes with empty categories * use page context in list.html (to avoid setting uniqueid in scratch) * use UniqueID instead of relative links for page identification
…rn into use-index-pages
Okay, so I never intended for mixing I've added a few workarounds, which should help, but the gist of it is that So yeah, I didn't think about wanting a non-chapter on the top level. So I changed how
in
Breadcrumbs were an honest oversight, I just didn't notice until now. That should be fixed. |
Use index pages + automatic navigation arrows
This PR enables using
_index.md
pages for chapters and adds automatic generation of navigation arrows (#22). I tried hard to keep this backwards-compatible, and it seems to be, for the most part. A caveat is that automatic navigationerrorsarrows may not work for legacy structure (withindex.md
pages) 100% of the time (although a hack to make it work most of the time is included).Changes:
_index.md
chapter: true
is unnecessary for_index.md
filesautoNav
enables automatic navigation arrows.prev
andnext
page metadata options are still supported as overrides. Settingprev: false
ornext: false
disables an arrow on that page.menu
site parameter is superseded by weight-based ordering of_index.md
pages. Weight of_index.md
pages works exactly like weight of normal pages, but on chapter level.All of those changes are recommendatory, i.e. it should still work with old sites just fine.