User Tools

Site Tools


blogging_with_jekyll

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
blogging_with_jekyll [2021/03/22 21:43] – [Output markup] hc9blogging_with_jekyll [2021/03/22 21:46] (current) – [Post template] hc9
Line 42: Line 42:
 ==== Output markup ==== ==== Output markup ====
  
-Output markup is fairly simple. The basic format is ''<nowiki>{{</nowiki> variable | filter <nowiki>}}</nowiki>''. The variables are typically built into Jekyll, so one usually doesn't have to worry about declaring them. ''site'' is a variable that stores site-wide information in sub-variables. For example, ''site.posts'' is a list of all the site's posts. Each post has its own ''post'' variable, which includes information such as ''post.title'', ''post.url'', and ''post.date'' Another important variable is "content", which is used in templates to denote where the content will be inserted. A complete list of template data can be found [[http://wiki.github.com/mojombo/jekyll/template-data|here]]. Filters are used to manipulate theoutput of variables. When a filter is not specified (''<nowiki>{{</nowiki> variable <nowiki>}}</nowiki>''), the variable is simply printed. Liquid has a bunch of built-in filters that can be found, along with a whole summary of using Liquid, [[http://wiki.github.com/tobi/liquid/liquid-for-designers|here]]. Jekyll also has some of its own filters, such as ''number_of_words'' and ''array_to_sentence_string'', which turns an array variable into a list of words separated by commas and an "and." The complete list can be found [[http://wiki.github.com/mojombo/jekyll/liquid-extensions| here]], along with Jekyll's extra tags.+Output markup is fairly simple. The basic format is ''<nowiki>{{</nowiki> variable | filter <nowiki>}}</nowiki>''. The variables are typically built into Jekyll, so one usually doesn't have to worry about declaring them. ''site'' is a variable that stores site-wide information in sub-variables. For example, ''site.posts'' is a list of all the site's posts. Each post has its own ''post'' variable, which includes information such as ''post.title'', ''post.url'', and ''post.date'' Another important variable is ''content'', which is used in templates to denote where the content will be inserted. A complete list of template data can be found [[http://wiki.github.com/mojombo/jekyll/template-data|here]]. Filters are used to manipulate theoutput of variables. When a filter is not specified (''<nowiki>{{</nowiki> variable <nowiki>}}</nowiki>''), the variable is simply printed. Liquid has a bunch of built-in filters that can be found, along with a whole summary of using Liquid, [[http://wiki.github.com/tobi/liquid/liquid-for-designers|here]]. Jekyll also has some of its own filters, such as ''number_of_words'' and ''array_to_sentence_string'', which turns an array variable into a list of words separated by commas and an "and." The complete list can be found [[http://wiki.github.com/mojombo/jekyll/liquid-extensions| here]], along with Jekyll's extra tags.
  
 ==== Tag markup ==== ==== Tag markup ====
Line 58: Line 58:
 ==== Post template ==== ==== Post template ====
  
-''post.html'' determines the layout for post pages. Here we first encounter YAML front matter. YAML stands for "YAML Ain't a Markup Language," Any YAML content is placed between ''<nowiki>---</nowiki>'' and ''<nowiki>---</nowiki>'' (each on their own line) at the beginning of a document. In this front matter we can set variables in the format, "variable: value". The only variable we need to set for the post template is "layout: default". This tells Jekyll to insert this template into ''<nowiki>{{</nowiki> content <nowiki>}}</nowiki>'' in the default layout. We'll also want to add a ''<nowiki>{{</nowiki> content <nowiki>}}</nowiki>'' to the post template. This is where the actual post will get inserted. We also might want to add somethings like ''<nowiki>{{</nowiki> page.title <nowiki>}}</nowiki>'' and ''<nowiki>{{</nowiki> page.date | date: "%A %d %B %Y" <nowiki>}}</nowiki>'', which will format the post's date as ''Weekday Day Month Year''.+''post.html'' determines the layout for post pages. Here we first encounter YAML front matter. YAML stands for "YAML Ain't a Markup Language," Any YAML content is placed between ''<nowiki>---</nowiki>'' and ''<nowiki>---</nowiki>'' (each on their own line) at the beginning of a document. In this front matter we can set variables in the format, ''variable: value''. The only variable we need to set for the post template is ''layout: default''. This tells Jekyll to insert this template into ''<nowiki>{{</nowiki> content <nowiki>}}</nowiki>'' in the default layout. We'll also want to add a ''<nowiki>{{</nowiki> content <nowiki>}}</nowiki>'' to the post template. This is where the actual post will get inserted. We also might want to add somethings like ''<nowiki>{{</nowiki> page.title <nowiki>}}</nowiki>'' and ''<nowiki>{{</nowiki> page.date | date: "%A %d %B %Y" <nowiki>}}</nowiki>'', which will format the post's date as ''Weekday Day Month Year''.
  
 ==== Other templates ==== ==== Other templates ====
blogging_with_jekyll.1616449406.txt.gz · Last modified: 2021/03/22 21:43 by hc9