Is there a way to include external links in the nav bar? I just see redirects when someone enters a particular /path, but not how to include links to an external website. Is there a plug-in I’ve missed, or perhaps I have to hardcode them into a custom theme?
I personally code this in myself in my templates.
Here’s my layout/partials/header.html
:
<header class = "title-bar">
<nav>
<span class = "site-title">
<a href = "{{ .Site.BaseURL }}">{{ .Site.Title }}</a>
</span>
<ul>
{{ $url := .RelPermalink }}
{{ with site.Menus.main }}
{{ range . }}
<li>
<a class="{{ if eq .URL $url }}active{{ end }}" href="{{ .URL }}">
{{ .Name }}
</a>
</li>
{{ end }}
{{ end }}
{{ range $menuitem := .Site.Params.Menu }}
<li>
<a class="{{ if eq .URL $url }}active{{ end }}"
href="{{ index $menuitem "url" }}">
{{ index $menuitem "name" }}
</a>
</li>
{{ end }}
{{ if .Site.Params.Contact }}
<li>
<a href="mailto:{{ .Site.Params.Contact }}">Contact</a>
</li>
{{ end }}
</ul>
</nav>
</header>
.site.Menus.main
is where Micro.blog stores pages that you have clicked “show in navigation”. I added my own list of URLs in my configuration under .Params.menu
.
Here’s what that part of my config looks like:
"params": {
"menu": [
{
"name": "Books",
"url": "/books"
},
{
"name": "Now",
"url": "/categories/now"
},
{
"name": "Archive",
"url": "/archive"
}
]
}
Now, in my case, those links are “local” but they could be arbitrary links-- I’m just passing the URL value to an anchor element.
An alternative approach is described here:
If you need to add more redirects, you can create a new page on your site: Posts → Pages → New Page. In the text contents, enter the full URL to redirect to:
Thanks! I haven’t delved into the templates yet, but I bookmarked in case I do.
Perfect, thank you! I was confused by the wording of that page, which made me think it was simply a way to add a large batch of redirects when transitioning over from another blog.
Hello, may I ask a question regarding this topic? I tried the redirect but it won`t work.
/newsletter → https://roh-ungefiltert.ghost.io
What am I missing? My URL: https://martinfehrensen.de
Kind regards, Martin