From b1fbc1d2da3bb5eaf0570785f1138c56ae998209 Mon Sep 17 00:00:00 2001 From: Shawn Borton Date: Sat, 21 Feb 2026 14:07:43 -0600 Subject: [PATCH] Fix org-hugo link export to render proper Markdown links - Handle http/https/ftp links explicitly using :raw-link for full URL - Resolve org-id links via org-id-find to use filename slug instead of raw UUID - Replace unused path alias with raw-link property Co-Authored-By: Claude Sonnet 4.6 --- config.el | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/config.el b/config.el index f4bc5ea..637cf3f 100644 --- a/config.el +++ b/config.el @@ -647,15 +647,23 @@ "Render org links as vanilla Markdown links instead of Hugo relref." (let* ((type (org-element-property :type link)) (raw-path (org-element-property :path link)) - (path raw-path)) + (raw-link (org-element-property :raw-link link))) (cond - ;; File links - convert to plain markdown + ;; External links - plain markdown + ((member type '("http" "https" "ftp")) + (format "[%s](%s)" (or desc raw-link) raw-link)) + ;; ID links - resolve org-id to file slug ((string= type "id") - (format "[%s](%s)" (or desc path) path)) + (let* ((id-location (org-id-find raw-path)) + (file (when id-location (car id-location))) + (slug (if file + (file-name-sans-extension (file-name-nondirectory file)) + raw-path))) + (format "[%s](%s)" (or desc slug) slug))) ;; Fuzzy/internal links - convert to anchor links ((string= type "fuzzy") - (format "[%s](#%s)" (or desc path) - (org-hugo-slug path))) + (format "[%s](#%s)" (or desc raw-path) + (org-hugo-slug raw-path))) ;; Default: use original behavior for other link types (t nil))))