This post is a demonstration of syntax highlighting in Jekyll using Pygments, for my presentation on Static Website Generators at Milwaukee Code Camp October 24, 2015

Pygments supports many languages a list of the can be found here.

Here is a bunch of Pygment themes for Jekyll.

HTML

>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
<div id="topbar" class="pure-menu pure-menu-open pure-menu-horizontal">
        <ul>
          <li><a href="/">Home</a></li>
          <li><a href="/downloads">Downloads</a></li>
          <li><a href="/archive">Archive</a></li>
          <li><a href="/about">About</a></li>
        </ul>
      </div>
      <div class="left">
        

<!doctype html>
<html lang="en" class="no-js">
  <head>
    

<meta charset="utf-8">



<!-- begin SEO -->









<title>YAML is Fussy About Formating - Data In » Knowledge Out</title>







<meta property="og:locale" content="en">
<meta property="og:site_name" content="Data In >> Knowledge Out">
<meta property="og:title" content="YAML is Fussy About Formating">


  <link rel="canonical" href="http://quentin-blacklock.github.io/programming/yaml-is-fussy-about-formating/">
  <meta property="og:url" content="http://quentin-blacklock.github.io/programming/yaml-is-fussy-about-formating/">



  <meta property="og:description" content="YAML, a markup language, is used in GitHubPages, Jekyll and many other static website generators for configuation information, front matter in posts, and defining data.">





  

  



  <meta property="og:image" content="/images/splash2.jpg">



  <meta property="og:type" content="article">
  <meta property="article:published_time" content="2015-10-13T00:00:00+00:00">








  <script type="application/ld+json">
    {
      "@context" : "http://schema.org",
      "@type" : "Person",
      "name" : "Quentin Blacklock",
      "url" : "http://quentin-blacklock.github.io",
      "sameAs" : null
    }
  </script>






<!-- end SEO -->


<link href="/feed.xml" type="application/atom+xml" rel="alternate" title="Data In >> Knowledge Out Feed">

<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<script>
  document.documentElement.className = document.documentElement.className.replace(/\bno-js\b/g, '') + ' js ';
</script>

<!-- For all browsers -->
<link rel="stylesheet" href="/assets/css/main.css">

<meta http-equiv="cleartype" content="on">
    <!-- start custom head snippets -->

<!-- insert favicons. use http://realfavicongenerator.net/ -->

<!-- end custom head snippets -->
  </head>

  <body>

    <!--[if lt IE 9]>
<div class="notice--danger align-center" style="margin: 0;">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</div>
<![endif]-->
    

<div class="masthead">
  <div class="masthead__inner-wrap">
    <div class="masthead__menu">
      <nav id="site-nav" class="greedy-nav">
        <button><div class="navicon"></div></button>
        <ul class="visible-links">
          <li class="masthead__menu-item masthead__menu-item--lg"><a href="/">Data In >> Knowledge Out</a></li>
          
            
            <li class="masthead__menu-item"><a href="/year-archive/">Posts</a></li>
          
            
            <li class="masthead__menu-item"><a href="/categories/">Categories</a></li>
          
            
            <li class="masthead__menu-item"><a href="/tags/">Tags</a></li>
          
            
            <li class="masthead__menu-item"><a href="/about/">About</a></li>
          
        </ul>
        <ul class="hidden-links hidden"></ul>
      </nav>
    </div>
  </div>
</div>

    


  









<div class="page__hero--overlay"
  style=" background-image: url('/images/splash2.jpg');"
>
  
    <div class="wrapper">
      <h1 class="page__title" itemprop="headline">
        
          YAML is Fussy About Formating

        
      </h1>
      
        <p class="page__lead">YAML, a markup language, is used in GitHubPages, Jekyll and many other static website generators for configuation information, front matter in posts, and defining data.

</p>
      
      
      
    </div>
  
  
    <span class="page__hero-caption">Photo credit: <a href="https://unsplash.com"><strong>Unsplash</strong></a>
</span>
  
</div>




<div id="main" role="main">
  


  <div class="sidebar sticky">
  



<div itemscope itemtype="http://schema.org/Person">

  <div class="author__avatar">
    
    	<img src="/images/bio-photo.jpg" class="author__avatar" alt="Quentin Blacklock">
    
  </div>

  <div class="author__content">
    <h3 class="author__name">Quentin Blacklock</h3>
    <p class="author__bio">Thoughts on software development, technology, knowledge management, strategic management.</p>
  </div>

  <div class="author__urls-wrapper">
    <button class="btn btn--inverse">Follow</button>
    <ul class="author__urls social-icons">
      
        <li><i class="fa fa-fw fa-map-marker" aria-hidden="true"></i> Sheboygan, WI</li>
      
      
      
      
      
        <li><a href="https://twitter.com/qblacklock"><i class="fa fa-fw fa-twitter-square" aria-hidden="true"></i> Twitter</a></li>
      
      
      
      
        <li><a href="https://www.linkedin.com/in/quentinblacklock"><i class="fa fa-fw fa-linkedin-square" aria-hidden="true"></i> LinkedIn</a></li>
      
      
      
      
      
      
        <li><a href="https://github.com/quentin-blacklock"><i class="fa fa-fw fa-github" aria-hidden="true"></i> Github</a></li>
      
      
      
      
      
      
      
      
      
      
      
      
      
    </ul>
  </div>
</div>

  
  </div>


  <article class="page" itemscope itemtype="http://schema.org/CreativeWork">
    <meta itemprop="headline" content="YAML is Fussy About Formating">
    <meta itemprop="description" content="YAML, a markup language, is used in GitHubPages, Jekyll and many other static website generators for configuation information, front matter in posts, and defining data.">
    <meta itemprop="datePublished" content="October 13, 2015">
    

    <div class="page__inner-wrap">
      

      <section class="page__content" itemprop="text">
        <p>YAML, a markup language, is used in GitHubPages, Jekyll and many other static website generators for configuation information, front matter in posts, and defining data.</p>

<p>YAML is fussy about formating and can be the cause of build errors in GitHub Page sites and Jekyll sites.</p>

<p>Bad YAML Example</p>

<figure class="highlight"><pre><code class="language-yaml" data-lang="yaml"><table style="border-spacing: 0"><tbody><tr><td class="gutter gl" style="text-align: right"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15</pre></td><td class="code"><pre><span class="nn">---</span> <span class="c1"># Tags for posts</span>
<span class="pi">-</span> <span class="s">slug</span><span class="pi">:</span> <span class="s">github</span>
   <span class="s">name</span><span class="pi">:</span> <span class="s">GitHub</span>

 <span class="pi">-</span> <span class="s">slug</span><span class="pi">:</span> <span class="s">github-pages</span>
    <span class="s">name</span><span class="pi">:</span> <span class="s">GitHub Pages</span>

 <span class="pi">-</span> <span class="s">slug</span><span class="pi">:</span> <span class="s">jekyll</span>
   <span class="s">name</span><span class="pi">:</span> <span class="s">Jekyll</span>
  
 <span class="pi">-</span> <span class="s">slug</span><span class="pi">:</span> <span class="s">that-conference-2015</span>
   <span class="s">name</span><span class="pi">:</span> <span class="s">That Conference 2015</span>
   
 <span class="pi">-</span> <span class="s">slug</span><span class="pi">:</span> <span class="s">yaml</span>
   <span class="s">name</span><span class="pi">:</span> <span class="s">YAML</span><span class="w">
</span></pre></td></tr></tbody></table></code></pre></figure>

<p>The miss-alignment of the indents in the first two tags can be the cause Page Build Failure emails from GitHubPages, or
this error when perfoming a jeykyll build command:</p>

<blockquote>
  <p>jekyll 2.5.3 | Error:  (/_data/tags.yml): 
mapping values are not allowed in this context at line 3 column 8</p>
</blockquote>

<p>Fortunalty there are a couple of YAML “Linting” tools online to help.</p>

<p><a href="http://www.yamllint.com/">YAML Lint</a></p>

<p><a href="http://codebeautify.org/yaml-validator">YAML Validator</a></p>

<p>Corrected YAML Example</p>

<figure class="highlight"><pre><code class="language-yaml" data-lang="yaml"><table style="border-spacing: 0"><tbody><tr><td class="gutter gl" style="text-align: right"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15</pre></td><td class="code"><pre><span class="nn">---</span> <span class="c1"># Tags for posts</span>
<span class="pi">-</span> <span class="s">slug</span><span class="pi">:</span> <span class="s">github</span>
  <span class="s">name</span><span class="pi">:</span> <span class="s">GitHub</span>

<span class="pi">-</span> <span class="s">slug</span><span class="pi">:</span> <span class="s">github-pages</span>
  <span class="s">name</span><span class="pi">:</span> <span class="s">GitHub Pages</span>

<span class="pi">-</span> <span class="s">slug</span><span class="pi">:</span> <span class="s">jekyll</span>
  <span class="s">name</span><span class="pi">:</span> <span class="s">Jekyll</span>
  
<span class="pi">-</span> <span class="s">slug</span><span class="pi">:</span> <span class="s">that-conference-2015</span>
  <span class="s">name</span><span class="pi">:</span> <span class="s">That Conference 2015</span>

<span class="pi">-</span> <span class="s">slug</span><span class="pi">:</span> <span class="s">yaml</span>
  <span class="s">name</span><span class="pi">:</span> <span class="s">YAML</span>   <span class="w">
</span></pre></td></tr></tbody></table></code></pre></figure>

<p>YAML is fussy about formating and can be the cause of build errors. Hard lesson learned. Hopefully this helps.</p>

        
      </section>

      <footer class="page__meta">
        
        


  




  
  
  

  <p class="page__taxonomy">
    <strong><i class="fa fa-fw fa-tags" aria-hidden="true"></i> Tags: </strong>
    <span itemprop="keywords">
    
      
      
      <a href="/tags/#github" class="page__taxonomy-item" rel="tag">github</a><span class="sep">, </span>
    
      
      
      <a href="/tags/#github-pages" class="page__taxonomy-item" rel="tag">github-pages</a><span class="sep">, </span>
    
      
      
      <a href="/tags/#jekyll" class="page__taxonomy-item" rel="tag">jekyll</a><span class="sep">, </span>
    
      
      
      <a href="/tags/#static-site-generators" class="page__taxonomy-item" rel="tag">static-site-generators</a><span class="sep">, </span>
    
      
      
      <a href="/tags/#yaml" class="page__taxonomy-item" rel="tag">yaml</a>
    
    </span>
  </p>




  






  
  
  

  <p class="page__taxonomy">
    <strong><i class="fa fa-fw fa-folder-open" aria-hidden="true"></i> Categories: </strong>
    <span itemprop="keywords">
    
      
      
      <a href="/categories/#programming" class="page__taxonomy-item" rel="tag">programming</a>
    
    </span>
  </p>


        
          <p class="page__date"><strong><i class="fa fa-fw fa-calendar" aria-hidden="true"></i> Updated:</strong> <time datetime="2015-10-13T00:00:00+00:00">October 13, 2015</time></p>
        
      </footer>

      

<section class="page__share">
  
    <h4 class="page__share-title">Share on</h4>
  

  <a href="https://twitter.com/intent/tweet?text=/programming/yaml-is-fussy-about-formating/" class="btn btn--twitter" title="Share on Twitter"><i class="fa fa-fw fa-twitter" aria-hidden="true"></i><span> Twitter</span></a>

  <a href="https://www.facebook.com/sharer/sharer.php?u=/programming/yaml-is-fussy-about-formating/" class="btn btn--facebook" title="Share on Facebook"><i class="fa fa-fw fa-facebook" aria-hidden="true"></i><span> Facebook</span></a>

  <a href="https://plus.google.com/share?url=/programming/yaml-is-fussy-about-formating/" class="btn btn--google-plus" title="Share on Google Plus"><i class="fa fa-fw fa-google-plus" aria-hidden="true"></i><span> Google+</span></a>

  <a href="https://www.linkedin.com/shareArticle?mini=true&url=/programming/yaml-is-fussy-about-formating/" class="btn btn--linkedin" title="Share on LinkedIn"><i class="fa fa-fw fa-linkedin" aria-hidden="true"></i><span> LinkedIn</span></a>
</section>

      


  <nav class="pagination">
    
      <a href="/programming/2015-what-i-learned-at-that-conference-post-1/" class="pagination--pager" title="What I Learned at That Conference 2015 Post 1
">Previous</a>
    
    
      <a href="/programming/syntax-highlighting-demo/" class="pagination--pager" title="Syntax Highlighing Demo
">Next</a>
    
  </nav>

    </div>

    
      

<div class="page__comments">
  <h4 class="page__comments-title">Leave a Comment</h4>
  
    <section id="disqus_thread"></section>
  
</div>
    
  </article>

  
  
    <div class="page__related">
      
        <h4 class="page__related-title">You May Also Enjoy</h4>
      
      <div class="grid__wrapper">
        
          





<div class="grid__item">
  <article class="archive__item" itemscope itemtype="http://schema.org/CreativeWork">
    
    <h2 class="archive__item-title" itemprop="headline">
      
        <a href="/programming/speaking/app-without-code-followup/" rel="permalink">Andriod Apps Without Code Follow Up
</a>
      
    </h2>
    
      <p class="page__meta"><i class="fa fa-clock-o" aria-hidden="true"></i> 


  
	  less than 1 minute read
	
</p>
    
    <p class="archive__item-excerpt" itemprop="description">Thank you to everyone who came to my session Android Apps Without Code at That Conference!

</p>
  </article>
</div>
        
          





<div class="grid__item">
  <article class="archive__item" itemscope itemtype="http://schema.org/CreativeWork">
    
    <h2 class="archive__item-title" itemprop="headline">
      
        <a href="/programming/speaking/speaking/" rel="permalink">Speaking at That Conference 2016
</a>
      
    </h2>
    
      <p class="page__meta"><i class="fa fa-clock-o" aria-hidden="true"></i> 


  
	  less than 1 minute read
	
</p>
    
    <p class="archive__item-excerpt" itemprop="description">I will be speaking at That Conference 2016 which happens August 8 - 10.

</p>
  </article>
</div>
        
          





<div class="grid__item">
  <article class="archive__item" itemscope itemtype="http://schema.org/CreativeWork">
    
    <h2 class="archive__item-title" itemprop="headline">
      
        <a href="/programming/milwaukee-code-camp/" rel="permalink">Milwaukee Code Camp Presentation
</a>
      
    </h2>
    
      <p class="page__meta"><i class="fa fa-clock-o" aria-hidden="true"></i> 


  
	  less than 1 minute read
	
</p>
    
    <p class="archive__item-excerpt" itemprop="description">On October 24, 2015 I gave a presentation on Static Website Generators at Milwakee Code Camp 2015.

</p>
  </article>
</div>
        
          





<div class="grid__item">
  <article class="archive__item" itemscope itemtype="http://schema.org/CreativeWork">
    
    <h2 class="archive__item-title" itemprop="headline">
      
        <a href="/programming/syntax-highlighting-demo/" rel="permalink">Syntax Highlighing Demo
</a>
      
    </h2>
    
      <p class="page__meta"><i class="fa fa-clock-o" aria-hidden="true"></i> 


  
	  less than 1 minute read
	
</p>
    
    <p class="archive__item-excerpt" itemprop="description">This post is a demonstration of syntax highlighting in Jekyll using Pygments, for my presentation  on Static Website Generators at Milwaukee Code Camp
Octobe...</p>
  </article>
</div>
        
      </div>
    </div>
  
</div>

    <div class="page__footer">
      <footer>
        <!-- start custom footer snippets -->

<!-- end custom footer snippets -->
        

<div class="page__footer-follow">
  <ul class="social-icons">
    
      <li><strong>Follow:</strong></li>
    
    
    
    
      <li><a href="http://github.com/quentin-blacklock"><i class="fa fa-fw fa-github" aria-hidden="true"></i> GitHub</a></li>
    
    
    <li><a href="/feed.xml"><i class="fa fa-fw fa-rss-square" aria-hidden="true"></i> Feed</a></li>
  </ul>
</div>

<div class="page__footer-copyright">&copy; 2016 Quentin Blacklock. Powered by <a href="http://jekyllrb.com" rel="nofollow">Jekyll</a> &amp; <a href="https://mademistakes.com/work/minimal-mistakes-jekyll-theme/" rel="nofollow">Minimal Mistakes</a>.</div>
      </footer>
    </div>

    <script src="/assets/js/main.min.js"></script>





  
  <script type="text/javascript">
  	/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
  	var disqus_shortname = 'quentin-blacklock';

  	/* * * DON'T EDIT BELOW THIS LINE * * */
  	(function() {
  		var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
  		dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
  		(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  	})();

  	/* * * DON'T EDIT BELOW THIS LINE * * */
  	(function () {
  		var s = document.createElement('script'); s.async = true;
  		s.type = 'text/javascript';
  		s.src = '//' + disqus_shortname + '.disqus.com/count.js';
  		(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
  	}());
  </script>
  <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>






  </body>
</html>

      </div>
</div>

C#

>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// A Hello World! program in C#.
using System;
namespace HelloWorld
{
    class Hello 
    {
        static void Main() 
        {
            Console.WriteLine("Hello World!");

            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}

Javascript

>
1
2
3
4
5
6
function loadScript(script, element) {
        var scr = document.createElement("script");
        scr.async = true;
        scr.src = script;
        (element || document.body).appendChild(scr);
}

F#

>
1
2
3
4
5
6
7
open System

[<EntryPoint>]
let main argv = 
    printfn "Hello World" 
    Console.ReadLine() |> ignore
    0 

Leave a Comment