diff --git a/templates/repo/issue/view_content/sidebar/reference.tmpl b/templates/repo/issue/view_content/sidebar/reference.tmpl
index 1b24531b7b..5083b97fc2 100644
--- a/templates/repo/issue/view_content/sidebar/reference.tmpl
+++ b/templates/repo/issue/view_content/sidebar/reference.tmpl
@@ -1,5 +1,10 @@
- {{$issueReferenceLink := printf "%s#%d" .Issue.Repo.FullName .Issue.Index}}
+ {{$issueReferenceLink := ""}}
+ {{if .Issue.IsPull}}
+ {{$issueReferenceLink = printf "%s!%d" .Issue.Repo.FullName .Issue.Index}}
+ {{else}}
+ {{$issueReferenceLink = printf "%s#%d" .Issue.Repo.FullName .Issue.Index}}
+ {{end}}
{{ctx.Locale.Tr "discussion.sidebar.reference"}}
diff --git a/tests/e2e/issue-sidebar.test.e2e.ts b/tests/e2e/issue-sidebar.test.e2e.ts
index 06cf1fb98f..f181185d69 100644
--- a/tests/e2e/issue-sidebar.test.e2e.ts
+++ b/tests/e2e/issue-sidebar.test.e2e.ts
@@ -349,3 +349,19 @@ test.describe('Dependency dropdown', () => {
await expect(depsBlock).toContainText('No dependencies set');
});
});
+
+test('Issue: Reference', async ({page}) => {
+ let response = await page.goto('/user2/repo1/pulls/5');
+ expect(response?.status()).toBe(200);
+
+ await expect(page.locator('.ui.reference .truncate')).toContainText(
+ 'user2/repo1!5',
+ );
+
+ response = await page.goto('/user2/repo1/issues/1');
+ expect(response?.status()).toBe(200);
+
+ await expect(page.locator('.ui.reference .truncate')).toContainText(
+ 'user2/repo1#1',
+ );
+});