-
-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to link to a page? #767
Comments
Hey 👋, don't be sorry. We are a friendly bunch of people. You could create a You could also add a Simple example would be: module.exports = {
'contact': '/contact'
} Which you can reference globally using <a href="{{ navigation.contact }}">Contact</a> You could also programmatically generate a navigation list in a similar way: module.exports = [
{
'label': 'Home',
'url': '/'
},
{
'label': 'About',
'url': '/about'
},
{
'label': 'Contact',
'url': '/contact'
}
] You can then construct a navigation anywhere on your site. <ul>
{% for item in navigation %}
<li><a href="{{ item.url }}">{{ item.label }}</a></li>
{% endfor %}
</ul> There's other ways to do this but this is a simple way to go about it. Using either helps you maintain the links in one place. |
Thank you very much for the explanations and examples :) |
@atomtigerzoo No problem :) |
YES THANK YOU @chrisssycollins—I love the tone you used here. I feel like I should maybe also plug the eleventy-navigation plugin which handles some of this for you https://github.com/11ty/eleventy-navigation |
Maybe also upvote #84 which would help here too |
|
Hi, sorry for the perhaps simple question, but I just don't get it :/
How can I link from - let's say the footer or any other page - to a given page inside11ty like the contact page
contact.njk
without writing/contact
?Or can I use something like my
navigation.js
file to create named links/pages and use those inside my templates or content?The text was updated successfully, but these errors were encountered: