List the siblings of the current page

I am trying to list the siblings of the current page, with each item on the next line with no blank lines between. I keep either getting blank lines between the items or I break the syntax somehow.

My test page is here:
http://globalforgivenessinitiative.com/about/test

I have this in the Front Matter
content:
items: ‘@self.siblings

test list1
{% for p in page.collection.order(‘folder’,‘asc’) %}
[{{ p.title }}]({{ p.url }})
{% endfor %}

If I put the above on the page it works but there are blank lines between the links.

Contact

reroutes

GFI Outreach Report 2017


test list2

If I do it like this try and remove the blank lines the blank lines do get removed but the links no longer work as the source is displayed.

    {% for p in page.collection.order('folder','asc') %}
  • [{{ p.title }}]({{ p.url }})
  • {% endfor %}

Outputs:
Contact
reroutes
GFI Outreach Report 2017


test list3

As a variation I tried doing it this way, but all the links get broken as the {{ p.url }} gets rendered as the http://globalforgivenessinitiative.com/about/{{%20p.url%20}}

    {% for p in page.parent.children if p != page %}
  • {{ p.title }}
  • {% endfor %}

Contact
reroutes
GFI Outreach Report 2017

(above 3 links all point to http://globalforgivenessinitiative.com/about/{{%20p.url%20}} )

I’ve tried a number of other variations, including switching on and off ‘Process Twig First’ and finally got convinced that I don’t know what I am doing and time to ask someone knowledgable. Anyone any ideas of how I can list links to siblings pages with no blank lines between them? :slight_smile:

I think code formatting has made your code hard to understand. Could you try reformatting your Twig as it’s not clear what it should say? You can format blocks of code by surrounding them with lines of “```”.

If you are on desktop you should see a preview on the right so can get it readable.

Hi Hughbris, I could not find a way to edit the first post, so I’ll repost below.


I am trying to list the siblings of the current page, with each item on the next line with no blank lines between. I keep either getting blank lines between the items or I break the syntax somehow.

My test page is here:
http://globalforgivenessinitiative.com/thereishope/pages/about/test


test list1
If I put the the code below on the page it works but there are blank lines between the links.

{% for p in page.collection.order(‘folder’,‘asc’) %}
[{{ p.title }}]({{ p.url }})
{% endfor %}


test list2
If I do it like this the blank lines do get removed but the links no longer work as the source is displayed.

    {% for p in page.collection.order('folder','asc') %}
  • [{{ p.title }}]({{ p.url }})
  • {% endfor %}
--- Output is like this:

Contact
reroutes
GFI Outreach Report 2017


test list3
As a variation I tried doing it this way, but all the links get broken as the {{ p.url }} gets rendered as “%7B%7B20p.url%20%7D%7D”

For example:
/about/%7B%7B20p.url%20%7D%7D

test list3

    {% for p in page.parent.children if p !- page %}
  • {{ p.title }}
  • {% endfor %}
---