Posts on Hugo Themes http://localhost:1313/posts/ Recent content in Posts on Hugo Themes Hugo -- gohugo.io en-US Sat, 22 Aug 2015 15:45:30 -0700 Redirect webpages using HTML http://localhost:1313/posts/redirect-webpages-html/ Sat, 22 Aug 2015 15:45:30 -0700 http://localhost:1313/posts/redirect-webpages-html/ <p>Webpage redirection is great for automatically redirecting people visiting an old URL to a new URL where the content has moved to. It can be done using JavaScript, but there is also a convenient HTML-only solution.</p> <p>To redirect visitors reaching <code>yourwebsite.com/blog</code> to <code>yourwebsite.com/posts</code>, add this to the <code>&lt;head&gt;</code> section of the HTML at <code>yourwebsite.com/blog</code>:</p> <p><div class="highlight"><pre><span class="nt">&lt;meta</span> <span class="na">http-equiv=</span><span class="s">&quot;refresh&quot;</span> <span class="na">content=</span><span class="s">&quot;0;url=&#39;/posts&#39;&quot;</span> <span class="nt">/&gt;</span> <span class="nt">&lt;link</span> <span class="na">rel=</span><span class="s">&quot;canonical&quot;</span> <span class="na">href=</span><span class="s">&quot;/posts&quot;</span> <span class="nt">/&gt;</span> </pre></div> </p> <h3 id="walkthrough:afdc852818bb97af4efb4d34b2fcce3b">walkthrough</h3> <p>Setting <code>http-equiv=&quot;refresh&quot;</code> in the first line performs the actual redirect. The number in the <code>content</code> attribute specified in seconds tells the browser how long to wait before redirecting. In this example, <code>0</code> redirects immediately. Increasing the wait may be useful for briefly displaying a 404 page before automatically switching to the home page. The <code>url</code> specfies the destination for the redirect. In this example, we wanted to switch to <code>/posts</code>.</p> <p>The second line is optional; it helps search engines know which the preferred version of the page is. Usually, this is the redirect destination.</p>