Hey, new to Grav - I’m looking to have a list of links that content editors can edit, stored as URL + Description, and have this list appear on every page of my Grav site. How would I go about doing this?
I’ve added a footer on every page of the website using a regular Grav markdown page as a source for the content, which can be edited by content editors like you describe:
- Add this code in
/user/themes/[themename]/partials/base.html.twig
where you want the links list to appear:
{% block links %}
{% set linkspage = pages.find('/links') %}
{% if linkspage %}
{% include 'partials/links.html.twig' %}
{% endif %}
{% endblock %}
- Add file
links.html.twig
to the same/partials
folder:
<div id="links">
{{ linkspage.content }}
</div>
- Add file
/user/pages/links/links.md
where you have your editable links list:
— markdown
title: links routable: false
My Links List
Link1
Description 1 here lorem ipsum
Link2
Description 2 here lorem ipsum
Link3
Description 3 here lorem ipsum
`routable: false`ensures [yourdomain.com]/links/ throws a 404 if you try to navigate to it directly.