Comments (4)
The problem here is Hugo. Not to pick on Hugo too much, I use it too and really like it in general, but in this regard I find its behavior quite unfortunate. Hugo expects you to use ref
and relref
shortcodes instead of using regular Markdown link syntax to sibling content files.
(If you try the exact same file layout with MkDocs, you'll find it works out of the box without issue)
I've found that Markdown Render Hooks allow us to work around the issue (make sure you're using goldmark
as your renderer).
Create the file layouts/_default/_markup/render-link.html
with the following contents:
{{- $url := urls.Parse .Destination -}}
{{- $scheme := $url.Scheme -}}
<a href="
{{- if eq $scheme "" -}}
{{- if strings.HasSuffix $url.Path ".md" -}}
{{- relref .Page .Destination | safeURL -}}
{{- else -}}
{{- .Destination | safeURL -}}
{{- end -}}
{{- else -}}
{{- .Destination | safeURL -}}
{{- end -}}"
{{- with .Title }} title="{{ . | safeHTML }}"{{- end -}}>
{{- .Text | safeHTML -}}
</a>
{{- /* whitespace stripped here to avoid trailing newline in rendered result caused by file EOL */ -}}
And layouts/_default/_markup/render-image.html
for images:
{{- $url := urls.Parse .Destination -}}
{{- $scheme := $url.Scheme -}}
<img src="
{{- if eq $scheme "" -}}
{{- if strings.HasSuffix $url.Path ".md" -}}
{{- relref .Page .Destination | safeURL -}}
{{- else -}}
{{- printf "/%s%s" .Page.File.Dir .Destination | safeURL -}}
{{- end -}}
{{- else -}}
{{- .Destination | safeURL -}}
{{- end -}}"
{{- with .Title }} title="{{ . | safeHTML }}"{{- end -}}
{{- with .Text }} alt="{{ . | safeHTML }}"
{{- end -}}
/>
{{- /* whitespace stripped here to avoid trailing newline in rendered result caused by file EOL */ -}}
Does that resolve the issue for you?
from obsidian-export.
Thanks for this solution. That made my day! I was horrified to have to change all native markdown links to < ref ... >
or < relref ... >
...
It works like a charm.
from obsidian-export.
Based on the lack of response I'm going to assume you either fixed your issue or lost interest in pursuing this.
from obsidian-export.
Based on the lack of response I'm going to assume you either fixed your issue or lost interest in pursuing this.
apologies for necro-ing this but ran into this same issue with mkdocs. Not too familiar with hugo but fwiw, the issue was the generated relative paths on windows were using unescaped "" as path separator
Swapping them with "/" fixed the issue. Presumably that should be the default, no? (only issue i can imagine is some static generators on Win7 that don't properly handle that as a separator)
from obsidian-export.
Related Issues (20)
- Adding option for angle bracket escaping over url-encoding HOT 1
- Add canvas export support
- feature request: add a flag to specify path prefix for wikilinks HOT 1
- Allow us to strip date from link generated
- Builds fail due to linting error HOT 3
- preserve mtime of source file
- Include titles
- Can't export to pdf with typst, unrecongnized subcommand HOT 1
- Why the restriction on symlinked folders?
- [Feature Request] Create tag to partially ignore content within a file. HOT 2
- Warning: Unable to find referenced note, is too verbose.
- Export only labeled files HOT 3
- Angular brackets incorrectly escaped in embedded Latex
- Postprocessor type does not enable storing state in the postprocessor
- Warning: Unable to find embedded note Reference: 'xxx' HOT 1
- Wikilinks filename followed by space not linked properly HOT 1
- Feature Request: continue even if error HOT 2
- Embedded link blocks don't work properly HOT 2
- Allow specifying directory relative to root for `--start-at` HOT 1
- Flag for export only nesessary attachements HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obsidian-export.