StaPy

Static Site Generator

How-to: How to display a list of links?

How to display a list of links?

Step 1

Open json file of the pages you want in the list:

source
+--- pages
    +--- my.page.html.json

Add a new tag in the tag list (here custom-list), and a position in the list:

{
    ...
    "title": "My Page",
    ...
    "tags": ["post", "sitemap", "custom-list"],
    "custom.list.position": 10,
    ...
}

Step 2

Open the HTML layout configuration file:

source
+--- layout
    +--- html.json

Add 2 new entries with the block template path:

{
    ...
    "custom.list": "template/block/custom-list.html",
    "custom.list.link": "template/block/custom-list/link.html",
    ...
}

Step 3

Create the new block template files with the HTML content:

source
+--- template
   +--- block
      +--- custom-list.html
      +--- custom-list
           +--- link.html

The custom-list.html template contains a query expression to retrieve all the pages with custom-list tag. We limit to the 100 first pages:

<ul>
    {% custom.list.link ~ tags:custom-list custom.list.position:asc 1:100 %}
</ul>

The custom-list/link.html template contains the HTML link element:

<li><a href="{{ url }}{{ $_path }}">{{ $title }}</a></li>

Next

How to add a new block?
How to add a new blog post?
How to display a list of links?
How to use dynamic data?
How to use Stapy on Windows?
How to host my static website for free?