<h1 dir="auto">Bug report</h1>
<h2 dir="auto">Describe the bug</h2>
<p dir="auto">Using <code class="notranslate">next/link</code> to visit a page inside a directory only changes the URL but doesn't load the page unless you reload the website.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=".
├── index.jsx
└── test
    └── index.jsx (broken)"><pre class="notranslate"><code class="notranslate">.
├── index.jsx
└── test
    └── index.jsx (broken)
</code></pre></div>
<h2 dir="auto">To Reproduce</h2>
<ol dir="auto">
<li>Create a page at <code class="notranslate">./pages/test/index.jsx</code> with the following contents</li>
</ol>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export default () =&gt; &lt;p&gt;Test Page&lt;/p&gt;"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-c1">&lt;</span><span class="pl-ent">p</span><span class="pl-c1">&gt;</span>Test Page<span class="pl-c1">&lt;</span><span class="pl-c1">/</span><span class="pl-ent">p</span><span class="pl-c1">&gt;</span></pre></div>
<ol start="2" dir="auto">
<li>Create another page at <code class="notranslate">./pages/index.jsx</code> with the following contents</li>
</ol>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import Link from 'next/link'

export default () =&gt; &lt;Link href=&quot;/test&quot;&gt;Go to Test&lt;/Link&gt;"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-v">Link</span> <span class="pl-k">from</span> <span class="pl-s">'next/link'</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-c1">&lt;</span><span class="pl-ent">Link</span> <span class="pl-c1">href</span><span class="pl-c1">=</span><span class="pl-s">"/test"</span><span class="pl-c1">&gt;</span>Go to Test<span class="pl-c1">&lt;</span><span class="pl-c1">/</span><span class="pl-ent">Link</span><span class="pl-c1">&gt;</span></pre></div>
<ol start="3" dir="auto">
<li>Visit <code class="notranslate">/test</code> in your browser</li>
<li>Notice that the page says <em>Test Page</em></li>
<li>Visit <code class="notranslate">/</code></li>
<li>Click <em>Go to Test</em></li>
<li>Notice that the URL changed but the page didn't</li>
<li>Reload the website</li>
<li>Notice that the page is now <code class="notranslate">/test</code> again</li>
</ol>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">The user should be sent to where they want to go without having to reload the page.</p>
<h2 dir="auto">Screenshots</h2>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/40307305/52733014-02cc7900-2f98-11e9-9c81-a55bf2ebb82a.gif"><img src="https://user-images.githubusercontent.com/40307305/52733014-02cc7900-2f98-11e9-9c81-a55bf2ebb82a.gif" alt="2019-02-13 13-58-27 2019-02-13 13_59_55" data-animated-image="" style="max-width: 100%;"></a></p>
<h2 dir="auto">System information</h2>
<ul dir="auto">
<li>OS: macOS</li>
<li>Browser (if applies) Firefox Developer Edition 66.0b7</li>
<li>Version of Next.js: <code class="notranslate">^8.0.1</code></li>
</ul>
<h1 dir="auto">Bug report</h1>
<p dir="auto">When you build next.js when the index page is located in <code class="notranslate">/index/index.js</code> instead of <code class="notranslate">/index.js</code> The client side script will not be executed when you access <code class="notranslate">http://localhost/</code>.</p>
<p dir="auto">The built index page will register with <code class="notranslate">/index</code> (as shown below)</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="(window.__NEXT_P = window.__NEXT_P || []).push([&quot;/index&quot;, function () {
  var e = n(&quot;gDgk&quot;);
  return {
    page: e.default || e
  }
}])"><pre class="notranslate"><span class="pl-kos">(</span><span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">__NEXT_P</span> <span class="pl-c1">=</span> <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">__NEXT_P</span> <span class="pl-c1">||</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-s">"/index"</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">var</span> <span class="pl-s1">e</span> <span class="pl-c1">=</span> <span class="pl-en">n</span><span class="pl-kos">(</span><span class="pl-s">"gDgk"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">return</span> <span class="pl-kos">{</span>
    <span class="pl-c1">page</span>: <span class="pl-s1">e</span><span class="pl-kos">.</span><span class="pl-c1">default</span> <span class="pl-c1">||</span> <span class="pl-s1">e</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">]</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">Moving the index.js to the pages root will restore the wanted behaviour.<br>
It took a while for me to figure out what the actual issue is as it's working just fine in dev mode.</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior, please provide code snippets or a repository:</p>
<ol dir="auto">
<li>Check out <a href="https://github.com/adlk/nextjs-index-issue">https://github.com/adlk/nextjs-index-issue</a></li>
<li>Run <code class="notranslate">npm install &amp;&amp; npm run build &amp;&amp; npm start</code></li>
<li>Check in DevTools if you have a log with <code class="notranslate">Home: component did mount</code></li>
</ol>
<h2 dir="auto">System information</h2>
<ul dir="auto">
<li>Version of Next.js: 8.0.0</li>
</ul>