Jekyll2016-11-22T03:56:55+00:00http://www.iangoodfellow.com/blog//Adding Disqus comments to a Jekyll blog2016-11-22T03:13:49+00:002016-11-22T03:13:49+00:00http://www.iangoodfellow.com/blog/disqus/jekyll/2016/11/22/adding-disqus-to-jekyll<p>I decided to add Disqus comments to this blog,
which is built using Jekyll and hosted on Github.
I found that the documentation for how to do this is inaccurate or out of date,
so I thought I would write down my own process.
I recommend comparing the date of this post to other posts you might find in
order to determine which is most likely to be relevant.
Fortunately, the latest procedure is even easier than the earlier procedures
that have been documented elsewhere.</p>
<p>I am using Jekyll version 3.3.0 and the minima theme.
These come with Disqus comments built into the default <code class="highlighter-rouge">_post.html</code> layout.
They need to be enabled though.</p>
<p>First, go to Disqus, register a shortname for your site, and add your site’s domain
to the list of trusted domains.</p>
<p>Now configure your Jekyll setup.
The logic in <code class="highlighter-rouge">_post.html</code> tests whether <code class="highlighter-rouge">site.disqus.shortname</code> has been configured,
and if so, it renders a Disqus comment section at the footer of the page.
To enable this, add the following to
<code class="highlighter-rouge">_config.yml</code>:</p>
<div class="highlighter-rouge"><pre class="highlight"><code>disqus:
shortname: yourshortname
</code></pre>
</div>
<p>where <code class="highlighter-rouge">yourshortname</code> should be replaced with the shortname that you personally
registered. Be sure to use spaces and not tabs for the indentation.</p>
<p>Finally, make sure that your <code class="highlighter-rouge">url</code> and <code class="highlighter-rouge">baseurl</code> variables are set correctly
in your <code class="highlighter-rouge">_config.yml</code>.
The minima theme uses these to configure the <code class="highlighter-rouge">disqus_url</code> variable used to request
the Disqus comments for a particular blog post, and the comments will fail to load
if they are not set correctly.</p>
<p>That’s it—once you push your changes, people should be able to comment on your
blog.</p>I decided to add Disqus comments to this blog,
which is built using Jekyll and hosted on Github.
I found that the documentation for how to do this is inaccurate or out of date,
so I thought I would write down my own process.
I recommend comparing the date of this post to other posts you might find in
order to determine which is most likely to be relevant.
Fortunately, the latest procedure is even easier than the earlier procedures
that have been documented elsewhere.Multiple custom domains with GitHub hosting2016-11-21T02:51:46+00:002016-11-21T02:51:46+00:00http://www.iangoodfellow.com/blog/github/domain/hosting/2016/11/21/custom-domains-on-github<p>As described in earlier posts, I host this website and blog using GitHub
Pages.
I also host <a href="www.deeplearningbook.org">www.deeplearningbook.org</a> using GitHub pages from the same
GitHub account.
Recently, I decided to start using a custom domain for this website.
I found the GitHub documentation for how to do so to be somewhat confusing,
and found other people struggling with the same issue, but did not find
the solution posted anywhere, so I decided I should write down what I
ended up doing.</p>
<p>Some of the GitHub documentation is ambiguous, and makes it sound to me
as if it might not be possible to use multiple custom domain names
with a single user accounts.
Examples in the documentation use a single custom domain with different
repositories being mapped to different subdomains or directories under
a domain.</p>
<p>Fortunately, GitHub does support different custom domains for each repository.
Setting them up is relatively simple once you know what to do, though
figuring it out by trial and error can be problematic since errors will take
your site down and take some time to fix due to the time it takes for DNS
updates to propagate.
Some of my readers may have noticed that <a href="www.deeplearningbook.org">www.deeplearningbook.org</a> had some
downtime while I was figuring this out.</p>
<p>Suppose we wish to take the GitHub pages hosted at <code class="highlighter-rouge">username.github.io/repo_n</code>
and have them appear at <code class="highlighter-rouge">www.custom_domain_n.com</code>, for multiple values of <code class="highlighter-rouge">n</code>.
The solution is:
* Using your domain name registrar (I use <a href="www.namecheap.com">www.namecheap.com</a>), for each <code class="highlighter-rouge">www.custom_domain_n.com</code>:
* Add an A record with host <code class="highlighter-rouge">@</code> and value <code class="highlighter-rouge">192.30.252.153</code>. Some of the GitHub
documentation seems to discourage the A record approach, but it is the only approach that worked
for me.
* Add an A record with host <code class="highlighter-rouge">@</code> and value <code class="highlighter-rouge">192.30.252.154</code>.
* Add a CNAME record with host <code class="highlighter-rouge">www</code> and value <code class="highlighter-rouge">username.github.io.</code>
Yes, there is supposed to be a <code class="highlighter-rouge">.</code> at the end of the value.
Some pages of the GitHub documentation seem to suggest that multiple domain names
will not all be support if they have a CNAME Record pointing to the same user account,
but this is fortunately not the correct interpretation of the documentation.
* You may also wish to add a URL redirect record so that <code class="highlighter-rouge">custom_domain_n.com</code> will take you to
<code class="highlighter-rouge">www.custom_domain_n.com</code>.
* On GitHub, for each repository, add the corresponding custom domain in the repository’s settings.</p>
<p>Using this approach, I was able to link <a href="www.iangoodfellow.com">www.iangoodfellow.com</a> to
<a href="goodfeli.github.io">goodfeli.github.io</a>
and
<a href="www.deeplearningbook.org">www.deeplearningbook.org</a>
to
<a href="goodfeli.github.io/book">goodfeli.github.io/book</a>
.</p>As described in earlier posts, I host this website and blog using GitHub
Pages.
I also host www.deeplearningbook.org using GitHub pages from the same
GitHub account.
Recently, I decided to start using a custom domain for this website.
I found the GitHub documentation for how to do so to be somewhat confusing,
and found other people struggling with the same issue, but did not find
the solution posted anywhere, so I decided I should write down what I
ended up doing.LaTeX in Jekyll2016-11-07T00:46:58+00:002016-11-07T00:46:58+00:00http://www.iangoodfellow.com/blog/jekyll/markdown/tex/2016/11/07/latex-in-markdown<p>To write about machine learning, I will naturally want to use some math
symbols. Using LaTeX math in Jekyll is
not completely straightforward,
so I will describe the process here.</p>
<p>The markdown syntax itself is straightforward enough.
Suppose we want to write
<script type="math/tex">\nabla_\boldsymbol{x} J(\boldsymbol{x})</script>.
The LaTeX code for this is <code class="highlighter-rouge">$ \nabla_\boldsymbol{x} J(\boldsymbol{x}) $</code>.
The markdown syntax uses $ one more time in each delimiter:
<code class="highlighter-rouge">$$ \nabla_\boldsymbol{x} J(\boldsymbol{x}) $$</code>.
So far so good.</p>
<p>Unfortunately, if we build the markdown and display the site,
none of the LaTeX expressions appear.
This is because we need to include MathJax, a JavaScript library
that does the actual rendering.
All of the instructions I have been able to find say to include this
script by modifying <code class="highlighter-rouge">_layouts/post.html</code>, but newer versions of
Jekyll do not create such a file by default.</p>
<p>Instead, we need to find the layout file bundled with the theme,
make our own copy of it in our local repository, then modify
that copy.
To find the files for the <code class="highlighter-rouge">minima</code> theme, we run
<code class="highlighter-rouge">bundle show minima</code>.
Now we can copy <code class="highlighter-rouge">post.html</code> and add the following to it:</p>
<div class="highlighter-rouge"><pre class="highlight"><code><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
</code></pre>
</div>
<p>MathJax will now render simple LaTeX expressions correctly.
Jekyll and MathJax do not offer all of the functionality of
LaTeX—there is no support for the LaTeX <code class="highlighter-rouge">usepackage</code> command,
so only the core LaTeX functionality that has been ported to
MathJax is available.
This is why I use <code class="highlighter-rouge">boldsymbol</code> rather than <code class="highlighter-rouge">bm</code> above.
There seem to be a few other rough edges, for example, LaTeX
expressions seem to cause extraneous line breaks when used in
blog post titles.</p>
<!--
It is possible to define math-mode macros:
`$$ \def\vx{\boldsymbol{x}} $$` -->To write about machine learning, I will naturally want to use some math
symbols. Using LaTeX math in Jekyll is
not completely straightforward,
so I will describe the process here.Blogging with GitHub and Jekyll2016-11-06T20:19:58+00:002016-11-06T20:19:58+00:00http://www.iangoodfellow.com/blog/jekyll/github/blog/2016/11/06/blogging-with-github-and-jekyll<p>I decided to start a blog.
Like <a href="http://karpathy.github.io/2014/07/01/switching-to-jekyll">Andrej Karpathy’s blog</a>, this one is built using
<a href="http://jekyllrb.com">Jekyll</a> and hosted by <a href="http://www.github.com">GitHub</a>.</p>
<p>This first post just describes how to set up Jekyll and GitHub for
a personal page / blog combo.
My github username is <code class="highlighter-rouge">goodfeli</code>.
I wanted a setup where I have a personal site at <a href="https://goodfeli.github.io">https://goodfeli.github.io</a>
and a blog at <a href="https://goodfeli.github.io/blog">https://goodfeli.github.io/blog</a>. Because it wasn’t immediately
obvious how to do this, I thought I should document the process.</p>
<ol>
<li>Register a GitHub account if you do not already have one.</li>
<li>Make a repository called <code class="highlighter-rouge"><username>.github.io</code>, in my case <code class="highlighter-rouge">goodfeli.github.io</code>.
Make another repository called <code class="highlighter-rouge">blog</code>.</li>
<li>(Optional) I recommend setting both repositories to be private.
Otherwise anyone can file a GitHub issue on the repository and it will
be publicly visible.</li>
<li>In your <code class="highlighter-rouge"><username.github.io></code> directory, make a branch called <code class="highlighter-rouge">master</code>.
Make an <code class="highlighter-rouge">index.html</code> file for your personal page.
Pushing this to GitHub will result in it being published to the web at
<a href="https://goodfeli.github.io">https://goodfeli.github.io</a>.
Note that we will not be making a <code class="highlighter-rouge">blog</code> subdirectory within this repository;
instead the separate <code class="highlighter-rouge">blog</code> repository will serve that content.</li>
<li>Install Jekyll following the instructions for your platform.</li>
<li>Run <code class="highlighter-rouge">jekyll new blog</code> and use the contents of the resulting directory to
initialize the <code class="highlighter-rouge">gh-pages</code> branch of your <code class="highlighter-rouge">blog</code> repository.
Yes, the <code class="highlighter-rouge"><username>.github.io</code> repository will serve the <code class="highlighter-rouge">master</code> branch
and the <code class="highlighter-rouge">blog</code> repository will serve the <code class="highlighter-rouge">gh-pages</code> branch.
Your blog with the default Jekyll files is now available,
in my case, at <a href="https://goodfeli.github.io/blog">https://goodfeli.github.io/blog</a>.</li>
</ol>I decided to start a blog.
Like Andrej Karpathy’s blog, this one is built using
Jekyll and hosted by GitHub.