Posts on Nishanth Shanmugham http://localhost:1313/posts/ Recent content in Posts on Nishanth Shanmugham Hugo -- gohugo.io en-US Tue, 25 Aug 2015 17:09:14 -0500 Use @ instead of HEAD http://localhost:1313/posts/use-at-instead-of-head/ Tue, 25 Aug 2015 17:09:14 -0500 http://localhost:1313/posts/use-at-instead-of-head/ <p>I recently discovered that from git version <a href="https://github.com/git/git/blob/master/Documentation/RelNotes/1.8.5.txt#L100">1.8.5</a> onwards, <code>@</code> can replace <code>HEAD</code>:</p> <p><div class="highlight"><pre><span class="nv">$ </span>git reset --hard @~2 <span class="nv">$ </span>git rebase -i @~10 <span class="nv">$ </span>git diff @~2..@~3 </pre></div> </p> <p>And also in most scenarios <code>HEAD</code> can be left out completely, so you can say:</p> <p><div class="highlight"><pre><span class="nv">$ </span>git reset -- @<span class="o">{</span>2<span class="o">}</span> </pre></div> </p> <p>instead of:</p> <p><div class="highlight"><pre><span class="nv">$ </span>git reset -- HEAD@<span class="o">{</span>2<span class="o">}</span> </pre></div> </p> <p>It takes some getting used to, but it&rsquo;s definitely faster than typing <code>HEAD</code>.</p> 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>