diff --git a/test/chpldoc/links/nested.doc.chpl b/test/chpldoc/links/nested.doc.chpl
new file mode 100644
index 000000000000..eb04d66a78c0
--- /dev/null
+++ b/test/chpldoc/links/nested.doc.chpl
@@ -0,0 +1,25 @@
+/*
+
+This test is to make sure that links for nested types are handled correctly. All of these links should resolve correctly
+
+- :type:`nested.A`
+- :proc:`nested.A.foo`
+- :type:`nested.A.B`
+- :proc:`nested.A.B.bar`
+- :proc:`nested.A.baz`
+- :type:`nested.C`
+- :proc:`nested.C.foo`
+
+*/
+module nested {
+ record A {
+ proc foo() {}
+ record B {
+ proc bar() {}
+ }
+ proc baz() {}
+ }
+ record C {
+ proc foo() {}
+ }
+}
diff --git a/test/chpldoc/links/nested.doc.chpldocopts b/test/chpldoc/links/nested.doc.chpldocopts
new file mode 100644
index 000000000000..02dbf6292e13
--- /dev/null
+++ b/test/chpldoc/links/nested.doc.chpldocopts
@@ -0,0 +1 @@
+-o docs
diff --git a/test/chpldoc/links/nested.doc.cleanfiles b/test/chpldoc/links/nested.doc.cleanfiles
new file mode 100644
index 000000000000..d8f8d46921aa
--- /dev/null
+++ b/test/chpldoc/links/nested.doc.cleanfiles
@@ -0,0 +1 @@
+docs
diff --git a/test/chpldoc/links/nested.doc.good b/test/chpldoc/links/nested.doc.good
new file mode 100644
index 000000000000..289cbd78ef49
--- /dev/null
+++ b/test/chpldoc/links/nested.doc.good
@@ -0,0 +1,7 @@
+Found link for reference '#nested.A'
+Found link for reference '#nested.A.foo'
+Found link for reference '#nested.A.B'
+Found link for reference '#nested.A.B.bar'
+Found link for reference '#nested.A.baz'
+Found link for reference '#nested.C'
+Found link for reference '#nested.C.foo'
diff --git a/test/chpldoc/links/nested.doc.prediff b/test/chpldoc/links/nested.doc.prediff
new file mode 100755
index 000000000000..003e24301777
--- /dev/null
+++ b/test/chpldoc/links/nested.doc.prediff
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+
+import sys
+import os
+import re
+
+testname = sys.argv[1]
+testout = sys.argv[2]
+
+html_file = f"docs/modules/nested.html"
+if not os.path.exists(html_file):
+ with open(testout, "w") as f:
+ print(f"Could not find '{html_file}'", file=f)
+ exit()
+
+html_output = ""
+with open(html_file, "r") as f:
+ html_output = f.read()
+
+output = []
+
+# find all the references from the docstring with the following regex
+reference_pat = re.compile('')
+for m in re.finditer(reference_pat, html_output):
+ # for each reference, check if the link exists
+ link = m.group(1)
+ if not re.search(f'