# Blogging with Julia code blocks

**URL:** <https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419>\
**Category:** General Usage\
**Tags:** question, web\
**Created:** [March 3, 2017, 4:23am UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419 "2017-03-03T04:23:41Z")\
**Posts on this page:** 17\
**Page:** 2

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 5, 2017, 6:03pm UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/21 "2017-03-05T18:03:56Z")

</div>

Thanks @dpsanders, I am working on an extension example for my research, hopefully it will work out well 🙂

@ChrisRackauckas has made a very good connection in the comments, feel free to add another comment if you have an extension in mind, always good to learn new interesting stuff! Appreciate your feedback.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [March 5, 2017, 7:10pm UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/22 "2017-03-05T19:10:22Z")

</div>

I just meant to show how to use exponential random variables in continuous time. At least the version I saw didn’t have a code example for that.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 5, 2017, 7:16pm UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/23 "2017-03-05T19:16:54Z")

</div>

Got it, I thought it would pollute the grand finale, I prefer to leave the mystery 🙂

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 6, 2017, 5:08am UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/24 "2017-03-06T05:08:49Z")

</div>

Thanks @ChrisRackauckas, submitted the feed to [juliabloggers.com](http://juliabloggers.com) just now.

---

<div class="post-metadata">

**Author:** ![mpastell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mpastell/32/350_2.png) [@mpastell](https://discourse.julialang.org/u/mpastell)\
**Post date:** [March 6, 2017, 6:19am UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/25 "2017-03-06T06:19:53Z")

</div>

@juliohm I would use the methods suggested by @Tamas_Papp above to work with Jekyll. It does mean you need come up with a separate Makefile for `jmd`s so it’s not ideal.

Also it doesn’t look too hard to write your own Converter for Jekyll [Plugins | Jekyll • Simple, blog-aware, static sites](https://jekyllrb.com/docs/plugins/#converters). You could e.g. write out the content to a temp file, run weave and read the converted contents back to Jekyll.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 6, 2017, 7:05am UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/26 "2017-03-06T07:05:43Z")

</div>

Given that the weaving is the most costly step, and woven files tend to be static after that, I prefer to keep it manual.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 6, 2017, 6:18pm UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/27 "2017-03-06T18:18:38Z")

</div>

@mpastell, my main concern with writing a converter is that it will rely on Weave.jl and won’t build on GitHub pages, correct?

---

<div class="post-metadata">

**Author:** ![mpastell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mpastell/32/350_2.png) [@mpastell](https://discourse.julialang.org/u/mpastell)\
**Post date:** [March 6, 2017, 6:34pm UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/28 "2017-03-06T18:34:18Z")

</div>

Correct. You’d need to run Jekyll locally and commit the build.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [March 8, 2017, 5:18am UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/29 "2017-03-08T05:18:39Z")

</div>

> [@ChrisRackauckas](#):
>
> I took a look at @oxinabox 's setup and it’s pretty clean.

No, it is not. It just has stuffed a lot of dust under the rug

> [@juliohm](#):
>
> @oxinabox solution is pasting the output manually, I think I will go with it.

Also, not that.  
Output (and everything else) is generated in any post tagged jupyer-notebook.

My solution is actually pretty convoluted and gross,  
is kind of a variation on what @ChrisRackauckas does,  
to generate blog posts from Jupyter Notebooks.  
I uses the script that is in [oxinabox.github.io/scripts/jupyter at master · oxinabox/oxinabox.github.io · GitHub](https://github.com/oxinabox/oxinabox.github.io/tree/master/scripts/jupyter) to generate the posts.  
It uses a custom nbconverter config, including a custom template (in nbconvert fashion using Jinja2).

I can no longer recall the difference between defining your own nbconverted config+template,  
and defining your own converter for notebook-\> jekyll

This then generates the Jekyll posts, which include the liquid templating for Highlighting.  
I hoped that I could get Kramdown to do the highlighting which would have made:

````julia
 ```julia
 #code here

````

```julia
blocks work.

But I could not, so I had to use the [Jekyll/Liquid way](https://jekyllrb.com/docs/templates/#code-snippet-highlighting), with the 

```

{% highlight julia %}  
#code here  
{% endhighlight %}

```julia

Which I think is worse.

The truely painful stuff was not in getting highlighting to work, it was in getting the Images in the output working.
I learnt a new level of hatred for nbconvert and jekyll that day.
```

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 10, 2017, 5:57am UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/30 "2017-03-10T05:57:18Z")

</div>

@oxinabox so Jekyll and Julia will never play well? What should we do about this issue?

---

<div class="post-metadata">

**Author:** ![mpastell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mpastell/32/350_2.png) [@mpastell](https://discourse.julialang.org/u/mpastell)\
**Post date:** [March 10, 2017, 8:21am UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/31 "2017-03-10T08:21:06Z")

</div>

What’s the problem with running Weave locally and pushing generated markdown to gh pages? I could add a Jekyll formatter to use `{% highlight julia %}` for code and correct figure paths for output.

I don’t use Jekyll myself so I’d appreciate if you opened an issue of whats missing.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [March 10, 2017, 2:35pm UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/32 "2017-03-10T14:35:02Z")

</div>

> juliohm  
> @oxinabox so Jekyll and Julia will never play well? What should we do about this issue?

Problem is, I am concluding, jekyll is just not a great platform.  
And nor is Jupyter.  
They are both merely better than other things for various reasons.  
You can make them both work,  
but nothing is loverly about doing.  
Merely, possible.

> mpastell  
> What’s the problem with running Weave locally and pushing generated markdown to gh pages?

I see nothing wrong with this plan.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 10, 2017, 8:21pm UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/33 "2017-03-10T20:21:34Z")

</div>

@mpastell could you please elaborate on how this is done with a simple example?

---

<div class="post-metadata">

**Author:** ![mpastell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mpastell/32/350_2.png) [@mpastell](https://discourse.julialang.org/u/mpastell)\
**Post date:** [March 11, 2017, 10:07am UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/34 "2017-03-11T10:07:14Z")

</div>

I set a simple example repo that should get you started, see: [https://github.com/mpastell/weave-ghpages-sample](https://github.com/mpastell/weave-ghpages-sample) . Let me know if something is not clear.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 12, 2017, 5:27pm UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/35 "2017-03-12T17:27:51Z")

</div>

Thank you @mpastell, that is awesome, I will look into the repo for future posts, just released a new one where I copy the Julia output manually again:

> **[Super fast pattern search: The FFT trick](https://juliohm.github.io/science/fft-trick/)**
>
> In today’s post, I would like to document an old trick in image processing sometimes referred to as “The FFT trick” for exhaustive pattern search.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 30, 2017, 8:21am UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/36 "2017-03-30T08:21:19Z")

</div>

**Update:** Weave.jl now works with Hugo (thanks @mpastell!) [This blog post](https://tpapp.github.io/post/blogging-weave-julia-hugo/) has links to the source of my blog if someone wants to implement this setup.

---

<div class="post-metadata">

**Author:** ![amellnik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amellnik/32/137_2.png) [@amellnik](https://discourse.julialang.org/u/amellnik)\
**Post date:** [March 30, 2017, 3:17pm UTC](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419/37 "2017-03-30T15:17:31Z")

</div>

I’m a bit late to this party, but I’m currently using [http://prismjs.com/](http://prismjs.com/) which can be used in a bunch of different platforms.

[Previous page](https://discourse.julialang.org/t/blogging-with-julia-code-blocks/2419.md?page=1)
