jekyll 1.0.0.beta3 → 1.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of jekyll might be problematic. Click here for more details.
- data/CONTRIBUTING.md +3 -2
- data/History.txt +10 -0
- data/README.textile +1 -2
- data/bin/jekyll +1 -4
- data/features/step_definitions/jekyll_steps.rb +0 -8
- data/jekyll.gemspec +5 -4
- data/lib/jekyll.rb +13 -3
- data/lib/jekyll/filters.rb +14 -0
- data/lib/jekyll/generators/pagination.rb +20 -8
- data/lib/jekyll/post.rb +4 -0
- data/lib/jekyll/site.rb +1 -0
- data/site/_posts/2012-07-01-configuration.md +84 -83
- data/site/_posts/2012-07-01-contributing.md +58 -37
- data/site/_posts/2012-07-01-extras.md +43 -31
- data/site/_posts/2012-07-01-frontmatter.md +60 -16
- data/site/_posts/2012-07-01-github-pages.md +39 -8
- data/site/_posts/2012-07-01-home.md +30 -11
- data/site/_posts/2012-07-01-installation.md +31 -8
- data/site/_posts/2012-07-01-migrations.md +34 -10
- data/site/_posts/2012-07-01-pages.md +49 -26
- data/site/_posts/2012-07-01-pagination.md +136 -43
- data/site/_posts/2012-07-01-permalinks.md +25 -15
- data/site/_posts/2012-07-01-plugins.md +94 -50
- data/site/_posts/2012-07-01-posts.md +75 -24
- data/site/_posts/2012-07-01-structure.md +68 -8
- data/site/_posts/2012-07-01-templates.md +62 -45
- data/site/_posts/2012-07-01-usage.md +36 -17
- data/site/_posts/2012-07-01-variables.md +133 -23
- data/site/css/style.css +1 -1
- data/test/source/_posts/2013-03-19-not-a-post.markdown/.gitkeep +0 -0
- data/test/test_filters.rb +17 -0
- data/test/test_post.rb +23 -0
- data/test/test_site.rb +3 -1
- metadata +11 -4
@@ -5,8 +5,15 @@ prev_section: templates
|
|
5
5
|
next_section: pagination
|
6
6
|
---
|
7
7
|
|
8
|
-
Jekyll supports a flexible way to build your site’s URLs. You can
|
9
|
-
|
8
|
+
Jekyll supports a flexible way to build your site’s URLs. You can specify the
|
9
|
+
permalinks for your site through the [Configuration](../configuration) or in the
|
10
|
+
[YAML Front Matter](../frontmatter) for each post. You’re free to choose one of
|
11
|
+
the built-in styles to create your links or craft your own. The default style is
|
12
|
+
`date`.
|
13
|
+
|
14
|
+
Permalinks are constructed by creating a template URL where dynamic elements are
|
15
|
+
represented by colon-prefixed keywords. For example, the default `date`
|
16
|
+
permalink is defined as `/:categories/:year/:month/:day/:title.html`.
|
10
17
|
|
11
18
|
## Template variables
|
12
19
|
|
@@ -23,7 +30,7 @@ specify the permalinks for your site through the [Configuration](../configuratio
|
|
23
30
|
<p><code>year</code></p>
|
24
31
|
</td>
|
25
32
|
<td>
|
26
|
-
<p>Year from the
|
33
|
+
<p>Year from the Post’s filename</p>
|
27
34
|
</td>
|
28
35
|
</tr>
|
29
36
|
<tr>
|
@@ -31,47 +38,51 @@ specify the permalinks for your site through the [Configuration](../configuratio
|
|
31
38
|
<p><code>month</code></p>
|
32
39
|
</td>
|
33
40
|
<td>
|
34
|
-
<p>Month from the
|
41
|
+
<p>Month from the Post’s filename</p>
|
35
42
|
</td>
|
36
43
|
</tr>
|
37
44
|
<tr>
|
38
45
|
<td>
|
39
|
-
<p><code>
|
46
|
+
<p><code>i_month</code></p>
|
40
47
|
</td>
|
41
48
|
<td>
|
42
|
-
<p>
|
49
|
+
<p>Month from the Post’s filename without leading zeros.</p>
|
43
50
|
</td>
|
44
51
|
</tr>
|
45
52
|
<tr>
|
46
53
|
<td>
|
47
|
-
<p><code>
|
54
|
+
<p><code>day</code></p>
|
48
55
|
</td>
|
49
56
|
<td>
|
50
|
-
<p>
|
57
|
+
<p>Day from the Post’s filename</p>
|
51
58
|
</td>
|
52
59
|
</tr>
|
53
60
|
<tr>
|
54
61
|
<td>
|
55
|
-
<p><code>
|
62
|
+
<p><code>i_day</code></p>
|
56
63
|
</td>
|
57
64
|
<td>
|
58
|
-
<p>
|
65
|
+
<p>Day from the Post’s filename without leading zeros.</p>
|
59
66
|
</td>
|
60
67
|
</tr>
|
61
68
|
<tr>
|
62
69
|
<td>
|
63
|
-
<p><code>
|
70
|
+
<p><code>title</code></p>
|
64
71
|
</td>
|
65
72
|
<td>
|
66
|
-
<p>
|
73
|
+
<p>Title from the Post’s filename</p>
|
67
74
|
</td>
|
68
75
|
</tr>
|
69
76
|
<tr>
|
70
77
|
<td>
|
71
|
-
<p><code>
|
78
|
+
<p><code>categories</code></p>
|
72
79
|
</td>
|
73
80
|
<td>
|
74
|
-
<p>
|
81
|
+
<p>
|
82
|
+
The specified categories for this Post. Jekyll automatically parses
|
83
|
+
out double slashes in the URLs, so if no categories are present, it
|
84
|
+
will ignore this.
|
85
|
+
</p>
|
75
86
|
</td>
|
76
87
|
</tr>
|
77
88
|
</tbody>
|
@@ -160,4 +171,3 @@ Given a post named: `/2009-04-29-slap-chop.textile`
|
|
160
171
|
</tr>
|
161
172
|
</tbody>
|
162
173
|
</table>
|
163
|
-
|
@@ -6,19 +6,27 @@ next_section: extras
|
|
6
6
|
---
|
7
7
|
|
8
8
|
Jekyll has a plugin system with hooks that allow you to create custom generated
|
9
|
-
content specific to your site. You can run custom code for your site
|
10
|
-
|
9
|
+
content specific to your site. You can run custom code for your site without
|
10
|
+
having to modify the Jekyll source itself.
|
11
11
|
|
12
12
|
<div class="note info">
|
13
13
|
<h5>Plugins on GitHub Pages</h5>
|
14
|
-
<p>
|
14
|
+
<p>
|
15
|
+
<a href="http://pages.github.com">GitHub Pages</a> is powered by Jekyll,
|
16
|
+
however all Pages sites are generated using the <code>--safe</code> option
|
17
|
+
to disable custom plugins for security reasons. Unfortunately, this means
|
18
|
+
your plugins won’t work if you’re deploying to GitHub Pages.<br><br>
|
19
|
+
You can still use GitHub Pages to publish your site, but you'll need to
|
20
|
+
convert the site locally and push the generated static files to your GitHub
|
21
|
+
repository instead of the Jekyll source files.
|
22
|
+
</p>
|
15
23
|
</div>
|
16
24
|
|
17
25
|
## Installing a plugin
|
18
26
|
|
19
|
-
In your site source root, make a `_plugins` directory. Place your plugins
|
20
|
-
|
21
|
-
|
27
|
+
In your site source root, make a `_plugins` directory. Place your plugins here.
|
28
|
+
Any file ending in `*.rb` inside this directory will be loaded before Jekyll
|
29
|
+
generates your site.
|
22
30
|
|
23
31
|
In general, plugins you make will fall into one of three categories:
|
24
32
|
|
@@ -28,9 +36,8 @@ In general, plugins you make will fall into one of three categories:
|
|
28
36
|
|
29
37
|
## Generators
|
30
38
|
|
31
|
-
You can create a generator when you need Jekyll to create additional
|
32
|
-
|
33
|
-
like this:
|
39
|
+
You can create a generator when you need Jekyll to create additional content
|
40
|
+
based on your own rules. For example, a generator might look like this:
|
34
41
|
|
35
42
|
{% highlight ruby %}
|
36
43
|
module Jekyll
|
@@ -68,8 +75,8 @@ end
|
|
68
75
|
{% endhighlight %}
|
69
76
|
|
70
77
|
In this example, our generator will create a series of files under the
|
71
|
-
`categories` directory for each category, listing the posts in each
|
72
|
-
|
78
|
+
`categories` directory for each category, listing the posts in each category
|
79
|
+
using the `category_index.html` layout.
|
73
80
|
|
74
81
|
Generators are only required to implement one method:
|
75
82
|
|
@@ -94,18 +101,20 @@ Generators are only required to implement one method:
|
|
94
101
|
|
95
102
|
## Converters
|
96
103
|
|
97
|
-
If you have a new markup language you’d like to
|
98
|
-
|
99
|
-
|
104
|
+
If you have a new markup language you’d like to use with your site, you can
|
105
|
+
include it by implementing your own converter. Both the Markdown and Textile
|
106
|
+
markup languages are implemented using this method.
|
100
107
|
|
101
108
|
<div class="note info">
|
102
109
|
<h5>Remember your YAML front-matter</h5>
|
103
|
-
<p>
|
104
|
-
|
110
|
+
<p>
|
111
|
+
Jekyll will only convert files that have a YAML header at the top, even for
|
112
|
+
converters you add using a plugin.
|
113
|
+
</p>
|
105
114
|
</div>
|
106
115
|
|
107
|
-
Below is a converter that will take all posts ending in
|
108
|
-
|
116
|
+
Below is a converter that will take all posts ending in `.upcase` and process
|
117
|
+
them using the `UpcaseConverter`:
|
109
118
|
|
110
119
|
{% highlight ruby %}
|
111
120
|
module Jekyll
|
@@ -114,7 +123,7 @@ module Jekyll
|
|
114
123
|
priority :low
|
115
124
|
|
116
125
|
def matches(ext)
|
117
|
-
ext =~
|
126
|
+
ext =~ /^\.upcase$/i
|
118
127
|
end
|
119
128
|
|
120
129
|
def output_ext(ext)
|
@@ -142,37 +151,46 @@ Converters should implement at a minimum 3 methods:
|
|
142
151
|
<td>
|
143
152
|
<p><code>matches</code></p>
|
144
153
|
</td>
|
145
|
-
<td>
|
146
|
-
|
147
|
-
|
148
|
-
|
154
|
+
<td><p>
|
155
|
+
Does the given extension match this converter's list of acceptable
|
156
|
+
extensions? Takes one argument: the file's extension (including the
|
157
|
+
dot). Must return <code>true</code> if it matches, <code>false</code>
|
158
|
+
otherwise.
|
159
|
+
</p></td>
|
149
160
|
</tr>
|
150
161
|
<tr>
|
151
162
|
<td>
|
152
163
|
<p><code>output_ext</code></p>
|
153
164
|
</td>
|
154
|
-
<td>
|
155
|
-
|
156
|
-
|
165
|
+
<td><p>
|
166
|
+
The extension to be given to the output file (including the dot).
|
167
|
+
Usually this will be <code>".html"</code>.
|
168
|
+
</p></td>
|
157
169
|
</tr>
|
158
170
|
<tr>
|
159
171
|
<td>
|
160
172
|
<p><code>convert</code></p>
|
161
173
|
</td>
|
162
|
-
<td>
|
163
|
-
|
164
|
-
|
174
|
+
<td><p>
|
175
|
+
Logic to do the content conversion. Takes one argument: the raw content
|
176
|
+
of the file (without YAML front matter). Must return a String.
|
177
|
+
</p></td>
|
165
178
|
</tr>
|
166
179
|
</tbody>
|
167
180
|
</table>
|
168
181
|
|
169
|
-
In our example, UpcaseConverter
|
182
|
+
In our example, `UpcaseConverter#matches` checks if our filename extension is
|
183
|
+
`.upcase`, and will render using the converter if it is. It will call
|
184
|
+
`UpcaseConverter#convert` to process the content. In our simple converter we’re
|
185
|
+
simply uppercasing the entire content string. Finally, when it saves the page,
|
186
|
+
it will do so with a `.html` extension.
|
170
187
|
|
171
188
|
## Tags
|
172
189
|
|
173
|
-
If you’d like to include custom liquid tags in your site, you can do so
|
174
|
-
|
175
|
-
|
190
|
+
If you’d like to include custom liquid tags in your site, you can do so by
|
191
|
+
hooking into the tagging system. Built-in examples added by Jekyll include the
|
192
|
+
`highlight` and `include` tags. Below is an example of a custom liquid tag that
|
193
|
+
will output the time the page was rendered:
|
176
194
|
|
177
195
|
{% highlight ruby %}
|
178
196
|
module Jekyll
|
@@ -213,16 +231,20 @@ At a minimum, liquid tags must implement:
|
|
213
231
|
</tbody>
|
214
232
|
</table>
|
215
233
|
|
216
|
-
You must also register the custom tag with the Liquid template engine as
|
234
|
+
You must also register the custom tag with the Liquid template engine as
|
235
|
+
follows:
|
217
236
|
|
218
237
|
{% highlight ruby %}
|
219
238
|
Liquid::Template.register_tag('render_time', Jekyll::RenderTimeTag)
|
220
239
|
{% endhighlight %}
|
221
240
|
|
222
|
-
In the example above, we can place the following tag anywhere in one of our
|
241
|
+
In the example above, we can place the following tag anywhere in one of our
|
242
|
+
pages:
|
223
243
|
|
224
244
|
{% highlight ruby %}
|
225
|
-
|
245
|
+
{% raw %}
|
246
|
+
<p>{% render_time page rendered at: %}</p>
|
247
|
+
{% endraw %}
|
226
248
|
{% endhighlight %}
|
227
249
|
|
228
250
|
And we would get something like this on the page:
|
@@ -233,7 +255,10 @@ And we would get something like this on the page:
|
|
233
255
|
|
234
256
|
### Liquid filters
|
235
257
|
|
236
|
-
You can add your own filters to the Liquid template system much like you can add
|
258
|
+
You can add your own filters to the Liquid template system much like you can add
|
259
|
+
tags above. Filters are simply modules that export their methods to liquid. All
|
260
|
+
methods will have to take at least one parameter which represents the input of
|
261
|
+
the filter. The return value will be the output of the filter.
|
237
262
|
|
238
263
|
{% highlight ruby %}
|
239
264
|
module Jekyll
|
@@ -249,7 +274,12 @@ Liquid::Template.register_filter(Jekyll::AssetFilter)
|
|
249
274
|
|
250
275
|
<div class="note">
|
251
276
|
<h5>ProTip™: Access the site object using Liquid</h5>
|
252
|
-
<p>
|
277
|
+
<p>
|
278
|
+
Jekyll lets you access the <code>site</code> object through the
|
279
|
+
<code>context.registers</code> feature of Liquid. For example, you can
|
280
|
+
access the global configuration file <code>_config.yml</code> using
|
281
|
+
<code>context.registers.config</code>.
|
282
|
+
</p>
|
253
283
|
</div>
|
254
284
|
|
255
285
|
### Flags
|
@@ -269,24 +299,35 @@ There are two flags to be aware of when writing a plugin:
|
|
269
299
|
<p><code>safe</code></p>
|
270
300
|
</td>
|
271
301
|
<td>
|
272
|
-
<p>
|
273
|
-
|
274
|
-
|
302
|
+
<p>
|
303
|
+
A boolean flag that informs Jekyll whether this plugin may be safely
|
304
|
+
executed in an environment where arbitrary code execution is not
|
305
|
+
allowed. This is used by GitHub Pages to determine which core plugins
|
306
|
+
may be used, and which are unsafe to run. If your plugin does not
|
307
|
+
allow for arbitrary code, execution, set this to <code>true</code>.
|
308
|
+
GitHub Pages still won't load your plugin, but if you submit it for
|
309
|
+
inclusion in core, it's best for this to be correct!
|
310
|
+
</p>
|
275
311
|
</td>
|
276
312
|
</tr>
|
277
313
|
<tr>
|
278
314
|
<td>
|
279
|
-
<p><code>
|
315
|
+
<p><code>priority</code></p>
|
280
316
|
</td>
|
281
317
|
<td>
|
282
|
-
<p>
|
283
|
-
|
318
|
+
<p>
|
319
|
+
This flag determines what order the plugin is loaded in. Valid values
|
320
|
+
are: <code>:lowest</code>, <code>:low</code>, <code>:normal</code>,
|
321
|
+
<code>:high</code>, and <code>:highest</code>. Highest priority
|
322
|
+
matches are applied first, lowest priority are applied last.
|
323
|
+
</p>
|
284
324
|
</td>
|
285
325
|
</tr>
|
286
326
|
</tbody>
|
287
327
|
</table>
|
288
328
|
|
289
|
-
To use one of the example plugins above as an illustration, here is how you’d
|
329
|
+
To use one of the example plugins above as an illustration, here is how you’d
|
330
|
+
specify these two flags:
|
290
331
|
|
291
332
|
{% highlight ruby %}
|
292
333
|
module Jekyll
|
@@ -298,16 +339,15 @@ module Jekyll
|
|
298
339
|
end
|
299
340
|
{% endhighlight %}
|
300
341
|
|
301
|
-
|
302
342
|
## Available Plugins
|
303
343
|
|
304
344
|
There are a few useful, prebuilt plugins at the following locations:
|
305
345
|
|
306
346
|
- [Truncate HTML while preserving markup structure](https://github.com/MattHall/truncatehtml) by [Matt Hall](http://codebeef.com)
|
307
|
-
- [Generic Blog Plugins by Jose Diaz-Gonzalez](https://github.com/josegonzalez/josediazgonzalez.com/tree/master/_plugins): Contains plugins for tags, categories, archives, as well as a few
|
347
|
+
- [Generic Blog Plugins by Jose Diaz-Gonzalez](https://github.com/josegonzalez/josediazgonzalez.com/tree/master/_plugins): Contains plugins for tags, categories, archives, as well as a few Liquid extensions
|
308
348
|
- [Domain Name Filter by Lawrence Woodman](https://github.com/LawrenceWoodman/domain_name-liquid_filter): Filters the input text so that just the domain name is left
|
309
|
-
- [Jekyll Plugins by Recursive Design](http://recursive-design.com/projects/jekyll-plugins/): Plugin to generate Project pages from
|
310
|
-
- [Tag Cloud Plugin from a Jekyll walk-through](http://vitobotta.com/how-to-migrate-from-wordpress-to-jekyll/): Plugin to generate a
|
349
|
+
- [Jekyll Plugins by Recursive Design](http://recursive-design.com/projects/jekyll-plugins/): Plugin to generate Project pages from GitHub readmes, a Category page plugin, and a Sitemap generator
|
350
|
+
- [Tag Cloud Plugin from a Jekyll walk-through](http://vitobotta.com/how-to-migrate-from-wordpress-to-jekyll/): Plugin to generate a tag cloud
|
311
351
|
- [Pygments Cache Path by Raimonds Simanovskis](https://github.com/rsim/blog.rayapps.com/blob/master/_plugins/pygments_cache_patch.rb): Plugin to cache syntax-highlighted code from Pygments
|
312
352
|
- [Delicious Plugin by Christian Hellsten](https://github.com/christianhellsten/jekyll-plugins): Fetches and renders bookmarks from delicious.com.
|
313
353
|
- [Ultraviolet plugin by Steve Alex](https://gist.github.com/480380): Jekyll Plugin for Ultraviolet
|
@@ -380,5 +420,9 @@ There are a few useful, prebuilt plugins at the following locations:
|
|
380
420
|
|
381
421
|
<div class="note info">
|
382
422
|
<h5>Jekyll Plugins Wanted</h5>
|
383
|
-
<p>
|
423
|
+
<p>
|
424
|
+
If you have a Jekyll plugin that you would like to see added to this list,
|
425
|
+
you should <a href="../contributing">read the contributing page</a> to find
|
426
|
+
out how to make that happen.
|
427
|
+
</p>
|
384
428
|
</div>
|
@@ -5,77 +5,121 @@ prev_section: frontmatter
|
|
5
5
|
next_section: pages
|
6
6
|
---
|
7
7
|
|
8
|
-
One of Jekyll’s best aspects is that it is “blog aware”. What does
|
8
|
+
One of Jekyll’s best aspects is that it is “blog aware”. What does this mean,
|
9
|
+
exactly? Well, simply put, it means that blogging is baked into Jekyll’s
|
10
|
+
functionality. If you write articles and publish them online, this means that
|
11
|
+
you can publish and maintain a blog simply by managing a folder of text-files on
|
12
|
+
your computer. Compared to the hassle of configuring and maintaining databases
|
13
|
+
and web-based CMS systems, this will be a welcome change!
|
9
14
|
|
10
15
|
## The Posts Folder
|
11
16
|
|
12
|
-
As
|
17
|
+
As explained on the [directory structure](../structure) page, the `_posts`
|
18
|
+
folder is where your blog posts will live. These files can be either
|
19
|
+
[Markdown](http://daringfireball.net/projects/markdown/) or
|
20
|
+
[Textile](http://textile.sitemonks.com/) formatted text files, and as long as
|
21
|
+
they have [YAML front-matter](../frontmatter), they will be converted from their
|
22
|
+
source format into an HTML page that is part of your static site.
|
13
23
|
|
14
24
|
### Creating Post Files
|
15
25
|
|
16
|
-
To create a new post, all you need to do is create a new file in the `_posts`
|
26
|
+
To create a new post, all you need to do is create a new file in the `_posts`
|
27
|
+
directory. How you name files in this folder is important. Jekyll requires blog
|
28
|
+
post files to be named according to the following format:
|
17
29
|
|
18
30
|
{% highlight bash %}
|
19
31
|
YEAR-MONTH-DAY-title.MARKUP
|
20
32
|
{% endhighlight %}
|
21
33
|
|
22
|
-
Where `YEAR` is a four-digit number, `MONTH` and `DAY` are both two-digit
|
34
|
+
Where `YEAR` is a four-digit number, `MONTH` and `DAY` are both two-digit
|
35
|
+
numbers, and `MARKUP` is the file extension representing the format used in the
|
36
|
+
file. For example, the following are examples of valid post filenames:
|
23
37
|
|
24
38
|
{% highlight bash %}
|
25
|
-
2011-12-31-new-years-eve-is-awesome.
|
39
|
+
2011-12-31-new-years-eve-is-awesome.md
|
26
40
|
2012-09-12-how-to-write-a-blog.textile
|
27
41
|
{% endhighlight %}
|
28
42
|
|
29
43
|
### Content Formats
|
30
44
|
|
31
|
-
|
45
|
+
All blog post files must begin with [YAML front- matter](../frontmatter). After
|
46
|
+
that, it's simply a matter of deciding which format you prefer. Jekyll supports
|
47
|
+
two popular content markup formats:
|
48
|
+
[Markdown](http://daringfireball.net/projects/markdown/) and
|
49
|
+
[Textile](http://textile.sitemonks.com/). These formats each have their own way
|
50
|
+
of marking up different types of content within a post, so you should
|
51
|
+
familiarize yourself with these formats and decide which one best suits your
|
52
|
+
needs.
|
32
53
|
|
33
54
|
## Including images and resources
|
34
55
|
|
35
|
-
|
56
|
+
Chances are, at some point, you'll want to include images, downloads, or other
|
57
|
+
digital assets along with your text content. While the syntax for linking to
|
58
|
+
these resources differs between Markdown and Textile, the problem of working out
|
59
|
+
where to store these files in your site is something everyone will face.
|
36
60
|
|
37
|
-
Because of Jekyll’s flexibility, there are many solutions to how to do this. One
|
61
|
+
Because of Jekyll’s flexibility, there are many solutions to how to do this. One
|
62
|
+
common solution is to create a folder in the root of the project directory
|
63
|
+
called something like `assets` or `downloads`, into which any images, downloads
|
64
|
+
or other resources are placed. Then, from within any post, they can be linked to
|
65
|
+
using the site’s root as the path for the asset to include. Again, this will
|
66
|
+
depend on the way your site’s (sub)domain and path are configured, but here some
|
67
|
+
examples (in Markdown) of how you could do this using the `site.url` variable in
|
68
|
+
a post.
|
38
69
|
|
39
70
|
Including an image asset in a post:
|
40
71
|
|
41
|
-
{% highlight
|
72
|
+
{% highlight text %}
|
42
73
|
… which is shown in the screenshot below:
|
43
|
-
![My helpful screenshot]({
|
74
|
+
![My helpful screenshot]({% raw %}{{ site.url }}{% endraw %}/assets/screenshot.jpg)
|
44
75
|
{% endhighlight %}
|
45
76
|
|
46
77
|
Linking to a PDF for readers to download:
|
47
78
|
|
48
|
-
{% highlight
|
49
|
-
… you can [get the PDF]({
|
79
|
+
{% highlight text %}
|
80
|
+
… you can [get the PDF]({% raw %}{{ site.url }}{% endraw %}/assets/mydoc.pdf) directly.
|
50
81
|
{% endhighlight %}
|
51
82
|
|
52
83
|
<div class="note">
|
53
84
|
<h5>ProTip™: Link using just the site root URL</h5>
|
54
|
-
<p>
|
85
|
+
<p>
|
86
|
+
You can skip the <code>{% raw %}{{ site.url }}{% endraw %}</code> variable
|
87
|
+
if you <strong>know</strong> your site will only ever be displayed at the
|
88
|
+
root URL of your domain. In this case you can reference assets directly with
|
89
|
+
just <code>/path/file.jpg</code>.
|
90
|
+
</p>
|
55
91
|
</div>
|
56
92
|
|
57
93
|
## Displaying an index of posts
|
58
94
|
|
59
|
-
It’s all well and good to have posts in a folder, but a blog is no use unless
|
95
|
+
It’s all well and good to have posts in a folder, but a blog is no use unless
|
96
|
+
you have a list of posts somewhere. Creating an index of posts on another page
|
97
|
+
(or in a [template](../templates)) is easy, thanks to the [Liquid template
|
98
|
+
language](http://liquidmarkup.org/) and its tags. Here’s a basic example of how
|
99
|
+
to create a list of links to your blog posts:
|
60
100
|
|
61
101
|
{% highlight html %}
|
62
102
|
<ul>
|
63
|
-
{
|
103
|
+
{% raw %}{% for post in site.posts %}{% endraw %}
|
64
104
|
<li>
|
65
|
-
<a href="{
|
105
|
+
<a href="{% raw %}{{ post.url }}{% endraw %}">{% raw %}{{ post.title }}{% endraw %}</a>
|
66
106
|
</li>
|
67
|
-
{
|
107
|
+
{% raw %}{% endfor %}{% endraw %}
|
68
108
|
</ul>
|
69
109
|
{% endhighlight %}
|
70
110
|
|
71
|
-
Of course, you have full control over how (and where) you display your posts,
|
111
|
+
Of course, you have full control over how (and where) you display your posts,
|
112
|
+
and how you structure your site. You should read more about [how templates
|
113
|
+
work](../templates) with Jekyll if you want to know more.
|
72
114
|
|
73
115
|
## Highlighting code snippets
|
74
116
|
|
75
|
-
Jekyll also has built-in support for syntax highlighting of code snippets using
|
117
|
+
Jekyll also has built-in support for syntax highlighting of code snippets using
|
118
|
+
[Pygments](../extras), and including a code snippet in any post is easy. Just
|
119
|
+
use the dedicated Liquid tag as follows:
|
76
120
|
|
77
|
-
{% highlight
|
78
|
-
{
|
121
|
+
{% highlight text %}
|
122
|
+
{% raw %}{% highlight ruby %}{% endraw %}
|
79
123
|
def show
|
80
124
|
@widget = Widget(params[:id])
|
81
125
|
respond_to do |format|
|
@@ -83,7 +127,7 @@ def show
|
|
83
127
|
format.json { render json: @widget }
|
84
128
|
end
|
85
129
|
end
|
86
|
-
{
|
130
|
+
{% raw %}{% endhighlight %}{% endraw %}
|
87
131
|
{% endhighlight %}
|
88
132
|
|
89
133
|
And the output will look like this:
|
@@ -100,7 +144,14 @@ end
|
|
100
144
|
|
101
145
|
<div class="note">
|
102
146
|
<h5>ProTip™: Show line numbers</h5>
|
103
|
-
<p>
|
147
|
+
<p>
|
148
|
+
You can make code snippets include line-numbers by adding the word
|
149
|
+
<code>linenos</code> to the end of the opening highlight tag like this:
|
150
|
+
<code>{% raw %}{% highlight ruby linenos %}{% endraw %}</code>.
|
151
|
+
</p>
|
104
152
|
</div>
|
105
153
|
|
106
|
-
|
154
|
+
These basics should be enough to get you started writing your first posts. When
|
155
|
+
you’re ready to dig into what else is possible, you might be interested in doing
|
156
|
+
things like [customizing post permalinks](../permalinks) or using [custom
|
157
|
+
variables](../variables) in your posts and elsewhere on your site.
|