From: "Sébastien Gendre" <seb@k-7.ch>
To: General discussions about Org-mode <emacs-orgmode@gnu.org>
Subject: Org-publish and attachment links
Date: Sun, 11 Aug 2024 04:40:21 +0200 [thread overview]
Message-ID: <87h6br4wa2.fsf@k-7.ch> (raw)
[-- Attachment #1: Type: text/plain, Size: 3711 bytes --]
Hello,
# TL;DR
When I export Org-mode documents with org-publish, it cannot resolve
links in format "[[attachment:image.png]]".
But when I export manually the same document with the export dispatcher,
the export work correctly and the attachment link is correctly resolved.
I don't know if it's a bug, or if it's planned to work like this and a
feature suggestion is needed. So, I post a message here.
# Context
I plan to write a little web documentation with Org-mode.
The documentation is split into multiple Org-mode files that I put into
a "./Pages/" folder.
Each org-mode document are converted to HTML with org-publish and the
function `org-html-publish-to-html`. The result is written into the
"./Public" folder.
And there is 2 kind of statics files:
* The ones needed on each pages, like the website logo or the CSS
* The files related to a specific page, like a screenshot
For the first kind, I have a "./Static/" folder which content is copied
to "./Public/static/" with org-publish and the function
`org-publish-attachment`.
For the second type, I use the Org-mode feature "attachment" to attach
each files into an Org-mode heading and (in my Org document) I write an
attachment link like these: [[attachment:image.png]]
[[attachment:code_template.tar.gz][Template of code]]
To publish these files, I also use org-publish and the function
`org-publish-attachment`. This time, from the folder "./Pages" to the
folder "./Public".
# How to replicate this problem
For this, I skip the CSS+JS folder.
1) Create directory called "test_documentation".
2) In "test_documentation/", create 1 directory:
* "Pages"
3) In "Page/", create 1 file named "Example.org"
4) In "Example.org", create a heading, attach a image file to it and
make an attachment link to this file (like "[[attachment:image.png]]")
5) In "test_documentation/", create a file named "publish.el" and write
this content in it:
;; Publish script for the website
;; Package load and configuration
;; Use org
(use-package org)
;; Use ox-publish
(use-package ox-publish)
;; Set publication configuration
(setq org-publish-project-alist
'(("pages-org"
:base-directory "./Pages/"
:base-extension "org"
:publishing-function org-html-publish-to-html
:publishing-directory "./public/")
("pages-attachment"
:base-directory "./Pages/"
:base-extension "jpg\\|png\\|gif\\|svg\\|zip"
:recursive t
:publishing-directory "./public/"
:publishing-function org-publish-attachment)))
;; Do the publication
(org-publish-all t)
6) Run this publish script with this command:
emacs -q --script publish.el
# What did I get
An error message:
Error: user-error ("Unable to resolve link: \"attachment:image.png\"")
mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode 0x181658ba93aef0da>))
debug-early-backtrace()
debug-early(error (user-error "Unable to resolve link: \"attachment:image.png\""))
user-error("Unable to resolve link: %S" "attachment:image.png")
org-export-data…
I cut from the org-export-data, because it is amazingly long and didn't
add any useful info.
# What did I expected
Attachment link would be resolved like with manual HTML export.
# Versions
* Emacs: 29.4
* Org-mode: 9.6.15
Best regards
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 849 bytes --]
next reply other threads:[~2024-08-11 2:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-11 2:40 Sébastien Gendre [this message]
2024-08-11 15:24 ` Org-publish and attachment links Ihor Radchenko
2024-08-11 19:52 ` Sébastien Gendre
2024-08-13 18:12 ` Ihor Radchenko
2024-08-14 8:25 ` Sébastien Gendre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h6br4wa2.fsf@k-7.ch \
--to=seb@k-7.ch \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).