Choose a Template
Documentation for template designers
Okay, this page is a bit different from the others. It is intended to be used by template designers. For most users, the recommended action is to choose a theme on the Appearance page without changing the templates. However, if you want to practice your web development skills, keep reading.
Below is a list of variables that you can insert into the templates so that some information is inserted programmatically, without you having to worry about it while you focus on the content of your website.
These variables must be inserted as follows: {{ item.subitem }}. For example, to place the name of the website somewhere on the page, simply insert {{ global.website_name }} in its HTML code.
For more advanced uses of the Twig syntax, read this page.
List of variables:
In the CSS section
- global (object) [go to Settings to edit its attributes]
- website_name (string)
- website_title (string)
- website_description (string)
- website_logo (string)
- website_url (string)
- website_favicon (string)
- website_language (string) ["en", "fr" ...]
- website_timezone (string) [... -01:00, +00:00, +01:00 ...)]
- timezone_abbreviation (string)
- dot_html_for_links (string) [".html" or "" if the user has decided to remove this file extension from URLs]
- share_button (boolean)
- article_in_feedback (boolean)
- articles_in_author_profile (boolean)
- feedback_uri_prefix (string)
- img_url_prefix (string)
- head_code_snippets (string) [HTML]
- comment_box_snippet (string) [HTML]
- footer_social_snippet (string) [HTML]
- user (object) [user-defined variables. Obs.: Edit them as a JSON object]
- strings (object) [strings for internationalization]
- [in the default_theme there are these strings: no_articles_found, in_section_label, series_label, timeline_label, header_search_placeholder, footer_social_header, footer_subscribe_text, footer_email_placeholder, footer_subscribe_button, previous_articles, initial_page, and next_articles]
- libreblog (object)
- logo (string) [data:image/svg+xml...]
- version (string)
In the HTML section
For all pages and components
- global (object) [same as above]
- media (object) [used in conjunction with the media_url function]
[uri of media resource] (object):
- url (string)
- uri (string)
- file_extension (string)
- size (string)
- alt_text (string)
- title (string)
- info (string)
- created (string)
- updated (string)
- type (string)
- download_mode (boolean)
- versions (string)
For all HTML templates except page components
- components (object)
- header (string) [HTML with the rendered template]
- footer (string) [HTML with the rendered template]
- [other component] (string) [HTML]
- search_js_file (string) ["search-(random number).js"] [inside this JS file, a variable called libreblogSearch is set. It is accessible in the scope of the pages]
[contents of libreblogSearch (array)]:
items:
- uri (string) [link to the article or series page]
- type (string) ['Article', 'Series']
- title (string)
- subtitle (string)
- searchable (string) [title + ";" + subtitle, normalized and in lower case]
- in_sitemap (integer) [0=no and 1=yes]
- created (string)
- published (string)
- updated (string)
- photo (object)
- url (string)
- uri (string)
- file_extension (string)
- size (string)
- alt_text (string)
- title (string)
- info (string)
- download_mode (boolean)
- versions (object)
- small (boolean)
- medium (boolean)
- large (boolean)
For the Header HTML, the Footer HTML and other page components
- navbar (array)
items:
- uri (string)
- label (string)
- location (string) ['Header', 'Footer' or another page component]
- type (string) ['Section', 'Series', 'Article', 'Author', 'External', or 'Label']
- reference (string) [format: '/{type}/{uri}.html' or URL (if type=External)]
- created (string) [format: dd/MM/yyyy hh:mm]
- updated (string) [format: dd/MM/yyyy hh:mm]
For the Main Page
- articles (array)
items:
- uri (string)
- type (string) ['Article', 'Page', or 'Analysis']
- highlight_mainpage (integer) [0=no and 1=yes]
- highlight_section (integer) [0=no and 1=yes]
- enable_comments (integer) [0=no and 1=yes]
- in_sitemap (integer) [0=no and 1=yes]
- title (string)
- subtitle (string)
- label (string)
- series_uri (string)
- section_uri (string)
- section_title (string)
- created (string) [format: dd/MM/yyyy hh:mm]
- updated (string) [format: dd/MM/yyyy hh:mm]
- authors_ids (string) [uris separated by ',']
- contents (string) [HTML]
- declared_values (object) [see the "declare" function]
- photo (object)
- url (string)
- uri (string)
- file_extension (string)
- size (string)
- alt_text (string)
- title (string)
- info (string)
- download_mode (boolean)
- versions (object)
- small (boolean)
- medium (boolean)
- large (boolean)
- photo_info (string)
- notes (string)
- status (string) ['Published' or 'Unpublished']
- series (array)
items:
- uri (string)
- highlight_mainpage (integer) [0=no and 1=yes]
- highlight_section (integer) [0=no and 1=yes]
- hide_search_engines (integer) [0=no and 1=yes]
- title (string)
- subtitle (string)
- section_uri (string)
- section_title (string)
- created (string) [format: dd/MM/yyyy hh:mm]
- updated (string) [format: dd/MM/yyyy hh:mm]
- authors_ids (string) [uris separated by ',']
- contents (string) [HTML]
- photo (object) [as in articles]
- photo_info (string)
- declared_values (object) [see the "declare" function]
- status (string)
- how_many_pages (number) [for pagination]
- current_page (number) [for pagination]
For the Section Page
- section (object)
- uri (string)
- title (string)
- description (string)
- created (string) [format: dd/MM/yyyy hh:mm]
- updated (string) [format: dd/MM/yyyy hh:mm]
- authors_ids (string) [uris separated by ',']
- authors (array[object]) [as in Articles]
- contents (string) [HTML]
- declared_values (object) [see the "declare" function]
- articles (array) [as in the Main Page, but without the section_title]
- series (array) [as in the Main Page, but without the section_title]
- how_many_pages (number) [for pagination]
- current_page (number) [for pagination]
For the Series Page
- series (object) [the individual series]
- uri (string)
- highlight_mainpage (integer) [0=no and 1=yes]
- highlight_section (integer) [0=no and 1=yes]
- in_sitemap (integer) [0=no and 1=yes]
- title (string)
- subtitle (string)
- section_uri (string)
- section_title (string)
- created (string) [format: dd/MM/yyyy hh:mm]
- updated (string) [format: dd/MM/yyyy hh:mm]
- published (string) [format: dd/MM/yyyy hh:mm]
- authors_ids (string) [uris separated by ',']
- authors (array[object]) [as in Articles]
- contents (string) [HTML]
- photo (object) [as in the Main Page]
- photo_info (string)
- declared_values (object) [see the "declare" function]
- status (string)
- articles (array) [as in the Main Page]
- how_many_pages (number) [for pagination]
- current_page (number) [for pagination]
- section (object) [the section of this series or an empty object, if none]
For the Author Page
- author (object)
- uri (string)
- name (string)
- contact (string)
- location (string)
- created (string) [format: dd/MM/yyyy hh:mm]
- updated (string) [format: dd/MM/yyyy hh:mm]
- photo (object) [as in the Main Page]
- photo_info (string)
- declared_values (object) [see the "declare" function]
- contents (string) [HTML]
- articles (array) [as in the Main Page, but without the section_title]
- series (array) [as in the Main Page, but without the section_title]
- how_many_pages (number) [for pagination]
- current_page (number) [for pagination]
- declared_values (object) [as in Articles]
For all types of Article [Article, Page, Analysis (and custom types)]
- article (object)
- uri (string)
- type (string) ['Article', 'Page', etc.]
- highlight_mainpage (integer) [0=no and 1=yes]
- highlight_section (integer) [0=no and 1=yes]
- enable_comments (integer) [0=no and 1=yes]
- in_sitemap (integer) [0=no and 1=yes]
- title (string)
- subtitle (string)
- label (string)
- series_uri (string)
- section_uri (string)
- section_title (string)
- created (string) [format: dd/MM/yyyy hh:mm]
- updated (string) [format: dd/MM/yyyy hh:mm]
- published (string) [format: dd/MM/yyyy hh:mm]
- authors_ids (string) [uris separated by ',']
- authors (array)
items:
- uri (string)
- type (string)
- name (string)
- email (string)
- bio (string)
- contact (string)
- location (string)
- photo (object) [as in the Main Page]
- contents (string) [HTML]
- contents (string) [HTML]
- photo (object) [as in the Main Page]
- photo_info (string)
- notes (string)
- declared_values (object) [see the "declare" function]
- status (string) ['Published' or 'Unpublished']
- section (object) [the section of this article or an empty object, if none]
- series (object) [the series of this article or an empty object, if none]
- relations (object)
- first_articles (object)
- [name of the relation] (array)
items:
- article (object)
- the same attributes as the Main Page, but without the section_title
- relation (object)
- uri (string)
- article1 (string) [uri of an article]
- article2 (string) [uri of an article]
- type (string)
- place (string) [a number or a date]
- contents (string) [HTML]
- created (string) [format: dd/MM/yyyy hh:mm]
- updated (string) [format: dd/MM/yyyy hh:mm]
- photo (object) [as in the Main Page]
- photo_info (string)
- authors_ids (string) [uris separated by ',']
- declared_values (object) [see the "declare" function]
- second_articles (object) [similar to the item first_articles]
Functions
- r(refId: string, args: object): string [inserts a reference and returns a string with an HTML element with an anchor link]
- img(imgId: string, args: object, options: object): string [returns a string with an IMG element. The possible attributes of options are: width (number), height (number), version (string), title (string/boolean), caption (string/boolean), alt (string/boolean) and style (string)]
- media_url(mediaId: string, media: object): string [returns the URL corresponding to the media ID]
- photo_version(photo: object, version: string): string [returns the URL of the requested image version. If it does not exist, it returns the smallest version that is larger than the one requested]
- reference(articleUri: string, pos: number): string [returns the reference ID related to a given reference position]
- references_length(articleUri: string): number [returns the number of references in an article]
- get_authors(ref: object): array[string] [returns the authors in a reference object]
- get_urls(ref: object): array[string] [returns the URLs (UR) in a reference object]
- get_py(ref: object): string [returns the publication year in a reference object]
- get_title(ref: object): string [returns the title in a reference object]
- get_type(ref: object): string [returns the type of a reference object. For example: "Journal Article"]
- get_tags(ref: object, tags: array): array[array] [it receives an array with the desired tags (note: this array may contain arrays with tags that function as synonyms. For example: [["VL", "VO", "T3"], "IS", "SP"]. If "VL" is found, the function will not search for the other tags within the internal array. The function returns an array with an array for each tag found. In this array, there are three elements (the tag itself, a label for the tag and the value found)]
- reference_loc(articleUri: string, pos: number): string [returns "Ibid." if the previous reference is equal to the given reference, "Loc. cit." if there is another reference equal to the given reference but not immediately preceding it, and "" for the other cases]
- declare(key: string, value: string, args: object): void [this function allows user-edited pages to pass information to templates]
- format_date(dateStr: string, options: object): string [formats dates in a human-readable format]
- iso_datetime(dateStr: string): string [formats dates according to the ISO 8601 standard]