diff --git a/src/calibre/gui2/tweak_book/widgets.py b/src/calibre/gui2/tweak_book/widgets.py index 941a03b167..05ba48c23c 100644 --- a/src/calibre/gui2/tweak_book/widgets.py +++ b/src/calibre/gui2/tweak_book/widgets.py @@ -760,7 +760,7 @@ class InsertLink(Dialog): else: target = target.split('#', 1)[0] target = self.container.href_to_name(target) - ans = ans.replace('_SOURCE_FILENAME_', self.source_name) + ans = ans.replace('_SOURCE_FILENAME_', self.source_name or '') ans = ans.replace('_DEST_FILENAME_', target or '') ans = ans.replace('_ANCHOR_', frag or '') return ans