--- layout: post title: "Custom Javascript In Jekyll Blogs" date: 2016-12-22 16:32:39 -0400 comments: true jsarr: - graphs/dag_default.js categories: Javascript --- Not that this graph has anything meaningful, but it was easy to create using [visjs.org](http://visjs.org/). Follow along and I'll show you have to create this on you Jekyll Blogs. You can also view a good [tutorial](http://blog.emmatosch.com/2016/03/09/using-custom-javascript-in-jekyll-blogs.html) by Emma Tosch.


## Step to Add Javascript on Github Pages #### Create a subdirectory {% highlight bash %} mkdir -p _includes/graphs {% endhighlight %} Create the following [```_includes/graphs/dag_default.js```](https://github.com/mchirico/mchirico.github.io/blob/master/_includes/graphs/dag_default.js), but don't include any ```script``` tags. #### Edit ```_includes/head.html``` You can view the full file [_includes/head.html](https://github.com/mchirico/mchirico.github.io/blob/master/_includes/head.html) but below are my changes. #### Modify ```_layout/post.html``` Note this needs to go near the bottom of the [_layout/post.html](https://github.com/mchirico/mchirico.github.io/blob/master/_layouts/post.html) #### Creating Pages Here's a sample header on my [markdown page](https://raw.githubusercontent.com/mchirico/mchirico.github.io/master/_posts/2016-12-22-JavascriptNetwork.markdown) {% highlight html %} --- layout: post title: "Adding Javascript " date: 2016-12-22 16:32:39 -0400 jsarr: - graphs/dag_default.js categories: Javascript --- {% endhighlight %} #### Reference If you get stuck, checkout the source [repository](https://github.com/mchirico/mchirico.github.io)