Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to include video in jekyll markdown blog

I just started blogging using jekyll. I write my posts in markdown. Now, I want to include a youtube video in my post. How can I do this?

Also, I dont really like the pygments highlighting provided by jekyll by default. Is there anyway I can change this to some other style? If yes, can you point me to some nice styles/plugins?

like image 993
jacksparrow007 Avatar asked May 10 '12 08:05

jacksparrow007


People also ask

Can you add video to GitHub pages?

4. Embedding videos and other web content. As you've already experienced, the nice thing about GitHub Pages (using jekyll) is that it doesn't just accept Markdown–it also accepts HTML code, meaning that you can insert things like embed codes to insert multimedia content.

Does Jekyll use markdown?

By default, Jekyll uses the kramdown Markdown processor with stock settings, but you can enable other kramdown options or even switch Jekyll to another Markdown processor. See the Jekyll Markdown configuration options documentation for more information.

Where do I put pictures in Jekyll?

Create /assets/images/ in the root of your project and place the image there. And if you're not hosting with GitHub Pages you can use the Jekyll Post Files plugin which allows you to organize your images alongside your posts. Don't use underscores in your folder names.


4 Answers

You should be able to put the HTML for embedding directly into your markdown. Under the video, there is a "Share" button, click on this, and then the "Embed" button, which should give you something that looks a little like:

<iframe width="420" height="315" src="http://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>

Just copy and paste that into your post, the Markdown preprocessor won't touch it.


For Pygments, there is a whole pile of CSS stylesheets for various colour themes in this repository, you could experiment with them. (Note that you will have to replace .codehilite with .highlight for these to work with Jekyll.)

like image 123
huon Avatar answered Oct 21 '22 20:10

huon


I did similar thing but in my case, simple copy and paste doesn't work. The error message is below:

REXML could not parse this XML/HTML:

To avoid this error, I deleted allowfullscreen from copied source as below:

<iframe width="480" height="360" src="http://www.youtube.com/embed/WO82PoAczTc" frameborder="0"> </iframe>

It is important that Adding a whitespace before the closing </iframe>.

Then, I succeeded to embed the video into my site.

like image 31
Feel Physics Avatar answered Oct 21 '22 19:10

Feel Physics


The html code to insert a youtube video can be produced in Jekyll using a simple plugin as described in https://gist.github.com/1805814.

The syntax becomes as simple as:

{% youtube oHg5SJYRHA0 %}
like image 16
Etienne Avatar answered Oct 21 '22 19:10

Etienne


In my case issue has been resolved with jQuery:

jQuery

$('.x-frame.video').each(function() {
  $(this).after("<iframe class=\"video\" src=\"" + ($(this).attr('data-video')) + "\" frameborder=\"0\"></iframe>");
});

Usage

<div class="x-frame video" data-video="http://player.vimeo.com/video/52302939"> </div>

Note that whitespace is required between <div> </div>

like image 6
Helga Konly Avatar answered Oct 21 '22 18:10

Helga Konly