User Tools

Site Tools


misc:zola_tips

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
misc:zola_tips [2022/12/25 22:20] – [Breadcrumbs] mithatmisc:zola_tips [2022/12/25 22:57] (current) – [Sections and _index.md] mithat
Line 23: Line 23:
 ''_index.md'' has special access to information about the section's sub-pages. The typical use case for this is listing blog entries. Also, ''_index.md'' files can (should? must?) specify not just the template they will use but also the (default?) template page used by sub-pages. ''_index.md'' has special access to information about the section's sub-pages. The typical use case for this is listing blog entries. Also, ''_index.md'' files can (should? must?) specify not just the template they will use but also the (default?) template page used by sub-pages.
  
-You don't need to have a ''_index.md'' file in a folder (except the root). If you don't, Zola does not formally consider it a section, but the pages defined in it are still accessible. You can define an ''index.md'' file in a folder if you don't need the abilities of a section.+You don't need to have a ''_index.md'' file in a folder (except the root---see below). If you don't, Zola does not formally consider it a section, but the pages defined in it are still accessible. You can define an ''index.md'' file in a folder if you don't need the abilities of a section.
  
 You can nest sections. You can nest sections.
Line 141: Line 141:
 No doubt, there are opportunities to stuff some of this into macros and/or partials and/or similar. No doubt, there are opportunities to stuff some of this into macros and/or partials and/or similar.
 ===== Breadcrumbs ===== ===== Breadcrumbs =====
-See this [[https://zola.discourse.group/t/breadcrumb/509/3|forum post]], reproduced here in case it goes away:+See this [[https://zola.discourse.group/t/breadcrumb/509/3|forum post]], reproduced and re-formatted here in case it goes away:
  
 <code twig> <code twig>
 {% block breadcrumb %} {% block breadcrumb %}
 <div class="breadcrumb-container"> <div class="breadcrumb-container">
-    <a class="breadcrumb-path" href="/">Home</a> +  <a class="breadcrumb-path" href="/">Home</a> 
-    {% set current = section | default(value=page) %} +  {% set current = section | default(value=page) %} 
-    {% for ancestor in current.ancestors %}+  {% for ancestor in current.ancestors %}
     {% if loop.first %}     {% if loop.first %}
-    {% continue %}+      {% continue %}
     {% endif %}     {% endif %}
     <span class="breadcrumb-separator">/</span>     <span class="breadcrumb-separator">/</span>
     {% set section = get_section(path=ancestor) %}     {% set section = get_section(path=ancestor) %}
     <a class="breadcrumb-path" href="{{ section.permalink }}">{{ section.title }}</a>     <a class="breadcrumb-path" href="{{ section.permalink }}">{{ section.title }}</a>
-    {% endfor %} +  {% endfor %} 
-    <span class="breadcrumb-separator">/</span> +  <span class="breadcrumb-separator">/</span> 
-    <a class="breadcrumb-path active" href="{{ current.permalink }}">{{ current.title }}</a>+  <a class="breadcrumb-path active" href="{{ current.permalink }}">{{ current.title }}</a>
 </div> </div>
 {% endblock breadcrumb %} {% endblock breadcrumb %}
 </code> </code>
misc/zola_tips.1672006800.txt.gz · Last modified: 2022/12/25 22:20 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki