diff --git a/docs/test/feature.md b/docs/test/feature.md
new file mode 100644
index 0000000000000..8fe5cbc782df6
--- /dev/null
+++ b/docs/test/feature.md
@@ -0,0 +1,6 @@
+---
+id: feature
+title: Sub-directory Test
+---
+
+Testing subdirectory
diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js
index 5889511637b3a..7f5b0ad7a2f23 100644
--- a/lib/core/DocsLayout.js
+++ b/lib/core/DocsLayout.js
@@ -28,6 +28,23 @@ class DocsLayout extends React.Component {
this.props.metadata.localized_id
] || this.props.metadata.title
: this.props.metadata.title;
+ const prevDir =
+ metadata.previous_id && metadata.previous_id.includes('/')
+ ? metadata.previous_id.split('/')[0]
+ : '.';
+ const curDir = metadata.id.includes('/') ? metadata.id.split('/')[0] : '.';
+ const nextDir =
+ metadata.next_id && metadata.next_id.includes('/')
+ ? metadata.next_id.split('/')[0]
+ : '.';
+ let prevLink = metadata.previous_id + '.html';
+ if (prevDir !== curDir && curDir != '.') {
+ prevLink = '../' + prevLink;
+ }
+ let nextLink = metadata.next_id + '.html';
+ if (nextDir !== curDir && curDir != '.') {
+ nextLink = '../' + nextLink;
+ }
return (