diff --git a/lib/util/__fixtures__/release-notes.txt b/lib/util/__fixtures__/release-notes.txt
index a75a96dcc679d176eb010860aad35a2e779fbe7c..3bccfd52826b725d77f46136afeb0605698fd6dd 100644
--- a/lib/util/__fixtures__/release-notes.txt
+++ b/lib/util/__fixtures__/release-notes.txt
@@ -13,3 +13,5 @@
 
 #### New Contributors
 * @​user made their first contribution in https://github.com/foo/foo/pull/2
+
+#### [Heading With Markdown Link](https://github.com/foo/foo/blob/HEAD/CHANGELOG.md#1234-2023-07-03)
diff --git a/lib/util/markdown.spec.ts b/lib/util/markdown.spec.ts
index 6a0793e1abaaca49ec6faeae0d688138f84a487c..11611a24f2055a4d7dc1a468442884b27a55d241 100644
--- a/lib/util/markdown.spec.ts
+++ b/lib/util/markdown.spec.ts
@@ -15,6 +15,7 @@ describe('util/markdown', () => {
       *   Issue or PR (fork): foo#1
       *   Issue or PR (project): remarkjs/remark#1
       *   Mention: @wooorm
+      *   Changelog heading with link: [v2.23.1](https://github.com/bootstrap-vue/bootstrap-vue/blob/HEAD/CHANGELOG.md#2231-2022-10-26)
     `;
 
     const after =
@@ -29,6 +30,7 @@ describe('util/markdown', () => {
         -   Issue or PR (fork): [foo#1](https://github.com/foo/repo/issues/1)
         -   Issue or PR (project): [remarkjs/remark#1](https://github.com/remarkjs/remark/issues/1)
         -   Mention: [@wooorm](https://github.com/wooorm)
+        -   Changelog heading with link: [v2.23.1](https://github.com/bootstrap-vue/bootstrap-vue/blob/HEAD/CHANGELOG.md#2231-2022-10-26)
     ` + '\n';
 
     it('works', async () => {
@@ -50,7 +52,9 @@ describe('util/markdown', () => {
         '* pnpm rebuild accepts --store-dir by @user in https://github.com/foo/foo/pull/1\n' +
         '\n' +
         '#### New Contributors\n' +
-        '* @user made their first contribution in https://github.com/foo/foo/pull/2\n';
+        '* @user made their first contribution in https://github.com/foo/foo/pull/2\n' +
+        '#### [Heading With Markdown Link](https://github.com/foo/foo/blob/HEAD/CHANGELOG.md#1234-2023-07-03)' +
+        '\n';
 
       const expected = Fixtures.get('release-notes.txt');
       expect(sanitizeMarkdown(input)).toEqual(expected);
diff --git a/lib/util/markdown.ts b/lib/util/markdown.ts
index 0af35f07f36790dc55930bbad447dc89f67ddfb9..715ec95e6c6e5d31fa0fc393a17788373377beda 100644
--- a/lib/util/markdown.ts
+++ b/lib/util/markdown.ts
@@ -6,7 +6,7 @@ import { regEx } from './regex';
 export function sanitizeMarkdown(markdown: string): string {
   let res = markdown;
   // Put a zero width space after every # followed by a digit
-  res = res.replace(regEx(/#(\d)/gi), '#​$1');
+  res = res.replace(regEx(/\W#(\d)/gi), '#​$1');
   // Put a zero width space after every @ symbol to prevent unintended hyperlinking
   res = res.replace(regEx(/@/g), '@​');
   res = res.replace(regEx(/(`\[?@)​/g), '$1');
diff --git a/lib/workers/repository/update/pr/changelog/__snapshots__/release-notes.spec.ts.snap b/lib/workers/repository/update/pr/changelog/__snapshots__/release-notes.spec.ts.snap
index 3777869d2b08101a192014fc56f3b4452e554aba..c0278ad6e01c755c9b88677e7b98013b0dbfd51c 100644
--- a/lib/workers/repository/update/pr/changelog/__snapshots__/release-notes.spec.ts.snap
+++ b/lib/workers/repository/update/pr/changelog/__snapshots__/release-notes.spec.ts.snap
@@ -57,7 +57,7 @@ exports[`workers/repository/update/pr/changelog/release-notes getReleaseNotesMd(
 -   **yargs:** correct support of bundled electron apps ([#1554](https://www.github.com/yargs/yargs/issues/1554)) ([a0b61ac](https://www.github.com/yargs/yargs/commit/a0b61ac21e2b554aa73dbf1a66d4a7af94047c2f))
 ",
   "notesSourceUrl": "https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md",
-  "url": "https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md#1520-httpswwwgithubcomyargsyargscomparev1510v1520-2020-03-01",
+  "url": "https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md#1520-2020-03-01",
 }
 `;
 
@@ -73,7 +73,7 @@ exports[`workers/repository/update/pr/changelog/release-notes getReleaseNotesMd(
 -   address ambiguity between nargs of 1 and requiresArg ([#1572](https://www.github.com/yargs/yargs/issues/1572)) ([a5edc32](https://www.github.com/yargs/yargs/commit/a5edc328ecb3f90d1ba09cfe70a0040f68adf50a))
 ",
   "notesSourceUrl": "https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md",
-  "url": "https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md#1530-httpswwwgithubcomyargsyargscomparev1520v1530-2020-03-08",
+  "url": "https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md#1530-2020-03-08",
 }
 `;
 
diff --git a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts
index 7f3071e55919f286f74747963bea8928b550f956..1b493fca5f19f2da11aa18c80677b77511b10773 100644
--- a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts
+++ b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts
@@ -1240,7 +1240,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
         expect(res).toMatchSnapshot({
           notesSourceUrl:
             'https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md',
-          url: 'https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md#1530-httpswwwgithubcomyargsyargscomparev1520v1530-2020-03-08',
+          url: 'https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md#1530-2020-03-08',
         });
       });
 
@@ -1270,7 +1270,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
         expect(res).toMatchSnapshot({
           notesSourceUrl:
             'https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md',
-          url: 'https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md#1520-httpswwwgithubcomyargsyargscomparev1510v1520-2020-03-01',
+          url: 'https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md#1520-2020-03-01',
         });
       });
 
diff --git a/lib/workers/repository/update/pr/changelog/release-notes.ts b/lib/workers/repository/update/pr/changelog/release-notes.ts
index b4db11ab34d740c72014f518570c691f7acacb2f..8dbfeeff1321adc6966a051a8e9a3fb0f2de4351 100644
--- a/lib/workers/repository/update/pr/changelog/release-notes.ts
+++ b/lib/workers/repository/update/pr/changelog/release-notes.ts
@@ -349,10 +349,11 @@ export async function getReleaseNotesMd(
               logger.trace({ body }, 'Found release notes for v' + version);
               // TODO: fix url
               const notesSourceUrl = `${baseUrl}${repository}/blob/HEAD/${changelogFile}`;
-              const url =
-                notesSourceUrl +
-                '#' +
-                title.join('-').replace(regEx(/[^A-Za-z0-9-]/g), '');
+              const mdHeadingLink = title
+                .filter((word) => !isUrl(word))
+                .join('-')
+                .replace(regEx(/[^A-Za-z0-9-]/g), '');
+              const url = `${notesSourceUrl}#${mdHeadingLink}`;
               body = massageBody(body, baseUrl);
               if (body?.length) {
                 try {