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?
Archive
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.twigwhere you want the links list to appear:
TWIG
{% block links %}
{% set linkspage = pages.find('/links') %}
{% if linkspage %}
{% include 'partials/links.html.twig' %}
{% endif %}
{% endblock %}
- Add file
links.html.twigto the same/partialsfolder:HTML<div id="links"> {{ linkspage.content }} </div>
- Add file
/user/pages/links/links.mdwhere 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
TXT
`routable: false`ensures [yourdomain.com]/links/ throws a 404 if you try to navigate to it directly.
Log in to reply.
Suggested topics
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 0 | 1351 | 9 years ago | ||
| 2 | 935 | 9 years ago | ||
| 2 | 4062 | 9 years ago | ||
| 1 | 2948 | 9 years ago | ||
| 3 | 1119 | 9 years ago |