-
Hi Sören - great work as always! Your theme is amazing and powers a lot of our work developing online textbooks for our students. I'm updating my fork to the latest version, and I may have encountered a bug (or an unhandled edge case) with the new local page link resolution. A quick sample site to demonstrate the issue: https://github.com/russfeld/hugo-test The site is configured to be served at a subdirectory using On the homepage, I include links to a branch bundle Branch Bundles
[Link to Branch](branch)
REF Shortcode to Branch: {{% ref "branch" %}}
[REF Link to Branch]({{% ref "branch" %}})
RELREF Shortcode to Branch: {{% relref "branch" %}}
[RELREF Link to Branch]({{% relref "branch" %}})
---
Leaf Bundles
[Link to Leaf](leaf)
REF Shortcode to Leaf: {{% ref "leaf" %}}
[REF Link to Leaf]({{% ref "leaf" %}})
RELREF Shortcode to Leaf: {{% relref "leaf" %}}
[RELREF Link to Leaf]({{% relref "leaf" %}}) On the website, these render correctly and all go to the correct page: However, when building the site, I get some warnings from those RELREF links (but not the REF links since they are absolute):
As I was debugging it, I realized that the I tried a quick fix by overriding that shortcode and adding a bit of code to strip the path from the {{- $basePath := strings.TrimRight "/" (urls.Parse $page.Site.BaseURL).Path }}
{{- if ne $basePath "" }}
{{- $path = strings.TrimPrefix $basePath $path }}
{{- end }} Let me know what you think - I'm happy to put together a PR if this is indeed a bug . Russ |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi Russell, thanks for the kind words. What you are doing in your fork is pretty amazing and I took a lot of inspiration from it (eg. modifiable topbars was a thing made with your use case in mind). I'll take a look into your example, later. |
Beta Was this translation helpful? Give feedback.
-
That was an interesting deep dive into Hugo's guts. Link render hooks are sometimes limited to their use case
https://discourse.gohugo.io/t/not-able-to-render-images/42948/4 In simple cases where you are using only the
If you also plan to use the additional options I am planing to provide overwritten |
Beta Was this translation helpful? Give feedback.
That was an interesting deep dive into Hugo's guts.
Link render hooks are sometimes limited to their use case
https://discourse.gohugo.io/t/not-able-to-render-images/42948/4
In simple cases where you are using only the
path
option of theref
/relref
shortcode, this can be circumvented by adding your ownlayouts/shortcodes/relref.html
with the following content:If you also plan to use the additional options
lang
andoutputFormat
, you'll have to wait until #850 is implemented.I am planing to provide overwritten
rel/relref
shortcodes with the theme that…