on master help sign in
Fixed some of Donald Curtis' remarks
commitea694663e1e2ed2781001996c0a2cc2c2e5fdbbb authorJasper Van der Jeugt <jaspervdj@gmail.com> dateMon 13 Jun 2011, 11:44 (15 years ago) parent176605a
1 file changed+29−4
web/tutorial.markdown+29−4
web/tutorial.markdown+29−4
@@ -77,7 +77,11 @@ directory as illustrated in this diagram:
7777![Brochure files](/images/brochure-files.png)
7878
7979No magic is involved at all -- we will precisely study how and why our items are
80−compiled like that. All of this is specified in the `hakyll.hs` file.
80+compiled like that. All of this is specified in the `hakyll.hs` file. You can
81+view the full `hakyll.hs` file online [here][brochure-hakyll.hs], or you can
82+look in the directory you cloned or downloaded.
83+
84+[brochure-hakyll.hs]: http://github.com/jaspervdj/hakyll-examples/blob/master/brochure/hakyll.hs
8185
8286### Images
8387
@@ -182,6 +186,14 @@ of the content *field* by using `$field$`, and that's it.
182186You might have noticed how we specify a compiler (`compile`), but we don't set
183187any `route`. Why is this?
184188
189+We need to compile the template because we will need it later. If we compile a
190+page later using `templates/default.html`, Hakyll needs to know what
191+`templates/default.html` is. Note that we could move template compilation to the
192+bottom of our code. The order doesn't matter -- Hakyll will determine that for
193+you. But if you don't compile `templates/default.html` as a template, Hakyll
194+will not be able to take it into account when deciding the compilation order.
195+
196+So, the `compile` needs to be there -- but why don't we set a `route` here?
185197Precisely because we don't want to our template to end up anywhere in our site
186198directory! We want to use it to lay out other items -- so we need to load
187199(compile) it, but we don't want to give it a real destination.
@@ -294,9 +306,22 @@ absolute URL's everywhere in our templates and code, e.g.:
294306<link rel="stylesheet" type="text/css" href="/css/default.css" />
295307~~~~~
296308
297−And Hakyll will translate this to a relative URL for each page. This means we
298−can host our site at `example.com` and `example.com/subdir` without changing a
299−single line of code.
309+Using the [relativizeUrlsCompiler], Hakyll will change this to:
310+
311+~~~~~{.haskell}
312+<link rel="stylesheet" type="text/css" href="css/default.css" />
313+~~~~~
314+
315+when we are compiling `index.html`, or
316+
317+~~~~~{.haskell}
318+<link rel="stylesheet" type="text/css" href="../css/default.css" />
319+~~~~~
320+
321+when we are compiling (some imaginary) `posts/foo.html`. So Hakyll will
322+translate this to a relative URL for each page. This means we can host our site
323+at `example.com` and `example.com/subdir` without changing a single line of
324+code.
300325
301326More tutorials are in the works...
302327