diff --git a/ox-hugo.el b/ox-hugo.el
index ab8e12f..7dd5f02 100644
--- a/ox-hugo.el
+++ b/ox-hugo.el
@@ -1667,6 +1667,10 @@ and rewrite link paths to make blogging more seamless."
(;; Else if the image is inline (with non-alt-text
;; attributes), use HTML
tag syntax.
inline-image
+ ;; The "target" and "rel" attributes would be meant for
+ ;; tags. So do not pass them to the
tag.
+ (plist-put attr :target nil)
+ (plist-put attr :rel nil)
(org-html--format-image source attr info))
(t ;Else use the Hugo `figure' shortcode.
;; Hugo `figure' shortcode named parameters.
@@ -1680,7 +1684,16 @@ and rewrite link paths to make blogging more seamless."
(attr . ,(plist-get attr :attr))
(attrlink . ,(plist-get attr :attrlink))
(width . ,(plist-get attr :width))
- (height . ,(plist-get attr :height))))
+ (height . ,(plist-get attr :height))
+ ;; While the `target' and `rel'
+ ;; attributes are not supported by
+ ;; the inbuilt Hugo `figure'
+ ;; shortcode, they can be used as
+ ;; intended if a user has a custom
+ ;; `figure' shortcode with the
+ ;; support added for those.
+ (target . ,(plist-get attr :target))
+ (rel . ,(plist-get attr :rel))))
(figure-param-str ""))
(dolist (param figure-params)
(let ((name (car param))
diff --git a/test/site/content-org/all-posts.org b/test/site/content-org/all-posts.org
index 19158d0..2afb385 100644
--- a/test/site/content-org/all-posts.org
+++ b/test/site/content-org/all-posts.org
@@ -8,6 +8,7 @@
#+MACRO: oxhugoissue =ox-hugo= Issue #[[https://github.com/kaushalmodi/ox-hugo/issues/$1][$1]]
#+MACRO: hugoissue =hugo= Issue #[[https://github.com/gohugoio/hugo/issues/$1][$1]]
#+MACRO: bfissue /Blackfriday/ Issue #[[https://github.com/russross/blackfriday/issues/$1][$1]]
+#+MACRO: commit commit [[https://github.com/kaushalmodi/ox-hugo/commit/$1][$1]]
#+AUTHOR:
@@ -2277,11 +2278,23 @@ automatically).
Above is a link to an image. The =width= attribute of /10%/ though
must apply *only* to the image, and not to the link.
-- Note :: The =target= attribute is discarded though in this case
- because of the Hugo =figure= shortcode limitation.. there is
- no way to pass the =target= or any other attribute to the
- == element inside the == element that the
- =figure= shortcode constructs.
+- Note 1 :: The =target= attribute is /ineffective/ in this case
+ because of the Hugo =figure= shortcode limitation.. there
+ is no way to pass the =target= or any other attribute to
+ the == element inside the == element that the
+ =figure= shortcode constructs ({{{commit(e92fcf00)}}}).
+- Note 2 :: Though, the =target= (and =rel=) attributes, if present,
+ are still passed on to the =figure= shortcode. So if a
+ user has a custom =figure= shortcode that makes use of
+ those arguments, things will "just work" :smile:.
+
+-----
+
+#+ATTR_HTML: :width 10% :target _self
+Above limitation is not posed if the image is inlined:
+[[https://orgmode.org/img/org-mode-unicorn-logo.png][https://orgmode.org/img/org-mode-unicorn-logo.png]] i.e. the =target=
+attribute will be added to the == tag correctly, as the =figure=
+shortcode is not used for inline images.
** Within the same post (Internal links) :internal_links:
*** Link to headings by name :toc:headings:export_option:
:PROPERTIES:
diff --git a/test/site/content/posts/links-with-target-attribute.md b/test/site/content/posts/links-with-target-attribute.md
index 6b3af81..c35f526 100644
--- a/test/site/content/posts/links-with-target-attribute.md
+++ b/test/site/content/posts/links-with-target-attribute.md
@@ -20,14 +20,27 @@ automatically).
## Image linked to image with `target` attribute {#image-linked-to-image-with-target-attribute}
-{{< figure src="https://orgmode.org/img/org-mode-unicorn-logo.png" width="10%" link="https://orgmode.org/img/org-mode-unicorn-logo.png" >}}
+{{< figure src="https://orgmode.org/img/org-mode-unicorn-logo.png" width="10%" target="_self" link="https://orgmode.org/img/org-mode-unicorn-logo.png" >}}
Above is a link to an image. The `width` attribute of _10%_ though
must apply **only** to the image, and not to the link.
-Note
-: The `target` attribute is discarded though in this case
- because of the Hugo `figure` shortcode limitation.. there is
- no way to pass the `target` or any other attribute to the
- `` element inside the `` element that the
- `figure` shortcode constructs.
+Note 1
+: The `target` attribute is _ineffective_ in this case
+ because of the Hugo `figure` shortcode limitation.. there
+ is no way to pass the `target` or any other attribute to
+ the `` element inside the `` element that the
+ `figure` shortcode constructs (commit [e92fcf00](https://github.com/kaushalmodi/ox-hugo/commit/e92fcf00)).
+
+Note 2
+: Though, the `target` (and `rel`) attributes, if present,
+ are still passed on to the `figure` shortcode. So if a
+ user has a custom `figure` shortcode that makes use of
+ those arguments, things will "just work" :smile:.
+
+---
+
+Above limitation is not posed if the image is inlined:
+
i.e. the `target`
+attribute will be added to the `` tag correctly, as the `figure`
+shortcode is not used for inline images.