How to add link on menu nav hugo site - yaml

How can I add a direct link onto a nav item in a menu opposed to a reference to a section?
in my config.toml, I've added a link but it first places the baseurl in front of it:
[menu]
[[menu.nav]]
name = "Summary"
URL = "services"
weight = 2
[[menu.nav]]
name = "Contact"
URL = "contact-us"
weight = 3
[[menu.nav]]
name = "Methods"
URL = "blog"
weight = 4
[[menu.nav]]
name = "Français"
url = "https://example.com/" #this is the link I want to add
weight = 5
I found this post, but don't know html so am unsure where to add a change in the layout/partials/navigation.html file.
My suspicion is it's somewhere in this range of the partial.
{{ if .IsHome }}
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto navigation-menu">
<li class="nav-item"><a class="nav-link" data-scroll href="#body">{{ with $.Site.Params.home }}{{ . }}{{ end }}</a></li>
{{ range $.Site.Menus.nav }}
<li class="nav-item"><a class="nav-link" data-scroll href="#{{ .URL }}">{{ .Name }}</a></li>
{{ end }}
</ul>
</div>
{{ else }}
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto navigation-menu">
<li class="nav-item"><a class="nav-link" data-scroll href="{{ $.Site.BaseURL }}#body">{{ with $.Site.Params.home }}{{ . }}{{ end }}</a></li>
{{ range $.Site.Menus.nav }}
<li class="nav-item"><a class="nav-link" data-scroll href="{{ $.Site.BaseURL }}#{{ .URL | absURL }}">{{ .Name }}</a></li>
{{ end }}
</ul>
</div>
{{ end }}
Thanks for any help!

The navigation URLs are not handled great by this theme. Try to replace
the href="{{ $.Site.BaseURL }}#{{ .URL | absURL }}" to href="{{ .URL |relURL }}". It should work for both internal and external links
{{ if .IsHome }}
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto navigation-menu">
<li class="nav-item"><a class="nav-link" data-scroll href="#body">{{ with $.Site.Params.home }}{{ . }}{{ end }}</a></li>
{{ range $.Site.Menus.nav }}
<li class="nav-item"><a class="nav-link" data-scroll href="{{ .URL | relURL }}">{{ .Name }}</a></li>
{{ end }}
</ul>
</div>
{{ else }}
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto navigation-menu">
<li class="nav-item"><a class="nav-link" data-scroll href="{{ $.Site.BaseURL }}#body">{{ with $.Site.Params.home }}{{ . }}{{ end }}</a></li>
{{ range $.Site.Menus.nav }}
<li class="nav-item"><a class="nav-link" data-scroll href="{{ .URL | relURL }}">{{ .Name }}</a></li>
{{ end }}
</ul>
</div>
{{ end }}
and in your config.yaml, add "/" before the internal link.
baseurl = "/"
[menu]
[[menu.nav]]
name = "Summary"
URL = "/services"
weight = 2
[[menu.nav]]
name = "Contact"
URL = "/contact-us"
weight = 3
[[menu.nav]]
name = "Methods"
URL = "/blog"
weight = 4
[[menu.nav]]
name = "Français"
url = "https://example.com/" #this is the link I want to add
weight = 5

Related

Route [product/products] not defined. (View:

hi m trying to get products related to that category from index page but it shows error, whole of these things are working fine at admin side but not at user side,
index.blade.php:
#foreach($categories as $category)
<div class="col-sm-10 col-md-8 col-lg-4 m-l-r-auto">
<!-- block1 -->
<div class="block1 hov-img-zoom pos-relative m-b-30">
<img src="{{ URL::to('/') }}/images/backend_images/category_images/{{ $category->category_image }}" class="img-thumbnail" style="width: 370px; height: 448px;" />
<div class="block1-wrapbtn w-size2">
<!-- Button -->
<a href="{{ route('product/products', $category->id) }}" class="flex-c-m size2 m-text2 bg3 hov1 trans-0-4">
{{ ucwords($category->category_name) }}
</a>
</div>
</div>
</div>
#endforeach
routes:
Route::get('/product/{id}','ProductController#products');
route:list
paste.ofcode.org/Yw3CU2MXdCQXpxh9H3vKYh
A better way to do this is to define your route with a name like this:
Route ::get('/product/{id}','ProductController#products')->name('product.products');
Then specify your link like this:
<a href="{{ route('product.products', $category->id) }}" class="flex-c-m size2 m-text2 bg3 hov1 trans-0-4">
{{ ucwords($category->category_name) }}
</a>
Change this:
<a href="{{ route('product/products', $category->id) }}" class="flex-c-m size2 m-text2 bg3 hov1 trans-0-4">
{{ ucwords($category->category_name) }}
</a>
To this:
<a href="{{ route('admin.product.show', $category->id) }}" class="flex-c-m size2 m-text2 bg3 hov1 trans-0-4">
{{ ucwords($category->category_name) }}
</a>

How to make not clickable dynamic menu for some in laravel?

I have a dynamic menu and sub menu in my website and want to make not clickable menu to only those menu that have sub menu.
here is code
#foreach($levels as $category)
<li class="text-black-50">
<a href="/category/{{ $category->slug }}" title="">
{{ $category->name }}
</a>
</li>
#if($category->children->count() > 0 )
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
#foreach($category->children as $child)
<li>
{{ $child->name }}
</li>
#endforeach
</ul>
</li>
#else
#endif
#endforeach
I quick solution over your code is don't use href att when the menu has a submenu. Using your code:
#foreach($levels as $category)
<li class="text-black-50">
#if($category->children->count() > 0 )
<a href="/category/{{ $category->slug }}" title="">
{{ $category->name }}
</a>
#else
<a style="pointer-events: none; cursor: default;">
{{ $category->name }}
</a>
#endif
</li>
#if($category->children->count() > 0 )
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
#foreach($category->children as $child)
<li>
{{ $child->name }}
</li>
#endforeach
</ul>
</li>
#else
#endif
#endforeach
I hope It's helps!

unexpected "=" in operand

I am getting this error in a Hugo theme and have modified the code to use a simple example from the Hugo documentation and still get an error.
unexpected "=" in operand
Hugo Version
Hugo Static Site Generator v0.40.1 linux/amd64 BuildDate: 2018-04-25T17:16:11Z
Go Version
go version go1.12 linux/amd64
I have copied this code directly from the GoHugo - Append example.
Error
ERROR 2019/03/11 09:24:53 theme/partials/work.html : template: theme/partials/work.html:3: unexpected "=" in operand
Simplified Template
{{ partial "global-header.html" . }}
{{ $s := slice "a" "b" "c" }}
{{ $s = $s | append "d" "e" }}
<h1>David</h1>
I originally got the error in the Hugo AirSpace template at line 13 of the work.html partial.
Sample Line
{{ $categories = $categories | append .category }}
Full Template
{{ partial "global-header.html" . }}
<!-- Portfolio Start -->
<section id="portfolio-work">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="block">
<div class="portfolio-menu">
<ul>
{{ $categories := slice }}
{{ range .Site.Data.work.portfolio }}
{{ $categories = $categories | append .category }}
{{ end }}
<li class="filter" data-filter="all">Everything</li>
{{ range ( $categories | uniq ) }}
<li class="filter" data-filter=".{{ . }}">{{ . }}</li>
{{ end }}
</ul>
</div>
<div class="portfolio-contant">
<ul id="portfolio-contant-active">
{{ range .Site.Data.work.portfolio }}
<li class="mix {{ .category }}">
<a class="venobox" href="{{ $.Site.BaseURL }}{{ .image }}">
<img class="img-responsive" src="{{ $.Site.BaseURL }}{{ .image }}" />
<div class="overly">
<div class="position-center">
<i class="fa fa-search fz-20"></i>
<h2>{{ .name }}</h2>
<p>{{ .description }}</p>
</div>
</a>
</li>
{{ end }}
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Clients Logo Section Start -->
<section id="clients-logo-section">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="block">
<div id="clients-logo" class="owl-carousel">
{{ range .Site.Data.work.clients }}
<div class="clients-logo-img">
<img src="{{ $.Site.BaseURL }}{{ .image }}" alt="Features">
</div>
{{ end }}
</div>
</div>
</div>
</div>
</div>
</section>
I found that my version of go was old and it needed updating to 1.11
I followed the instructions found here
install-go-1-11-on-ubuntu
I had one slight variation, I used Go1.12 instead of 1.11
# From the docs
sudo tar -xvf go1.11.linux-amd64.tar.gz
# This is the latest version when I updated
sudo tar -xvf go1.12.linux-amd64.tar.gz
I also had to update my version of hugo.
Any time I did the following
sudo apt-get install hugo
I ended up with version 40
I followed the instructions here to go to version 53 of GO

How to make different icon url in laravel breadcrump?

Hi guys i have trouble in making different icon for url using laravel breadcrump, , here the picture
I want to make icon HRMS and Dashboard is different
Here my blade file
<link rel="stylesheet" type="text/css" href="{{ asset("/css/hrms2.css") }}">
#if (count($breadcrumbs))
<ol class="breadcrumb">
#foreach ($breadcrumbs as $breadcrumb)
#if ($breadcrumb->url && !$loop->last)
<li class="breadcrumb-item" style="">
<a class="bread-color" href="{{ $breadcrumb->url }}">
<i class="fa fa-home"></i> {{ $breadcrumb->title }}</a>
</li>
#else
<li class="breadcrumb-item active">{{ $breadcrumb->title }}</li>
#endif
#endforeach
</ol>
#endif
You need to pass icon name also in $breadcrumb object and use $breadcrumb->icon instead of fa-home
<ol class="breadcrumb">
#foreach ($breadcrumbs as $breadcrumb)
#if ($breadcrumb->url && !$loop->last)
<li class="breadcrumb-item" style=""><a class="bread-color" href="{{ $breadcrumb->url }}"> <i class="fa {{ $breadcrumb->icon }}"></i> {{ $breadcrumb->title }}</a></li>
#else
<li class="breadcrumb-item active">{{ $breadcrumb->title }}</li>
#endif
#endforeach

Change Index BLog to Directory Blog [Jekyll]

How do I replace a blog list of index
example: mysite.com to mysite.com/blog
I have copied from the index and make myste.com/blog.html , but it does not work
---
layout: default
---
<div class="home">
<div class="site-header-container {% if site.cover %}has-cover{% endif %}" {% if site.cover %}style="background-image: url({{ site.cover | prepend: site.baseurl }});"{% endif %}>
<div class="scrim {% if site.cover %}has-cover{% endif %}">
<header class="site-header">
<h1 class="title">{{ site.title }}</h1>
{% if site.subtitle %}<p class="subtitle">{{ site.subtitle }}</p>{% endif %}
</header>
</div>
</div>
<div class="wrapper">
<ul class="post-list">
{% for post in paginator.posts %}
<li>
<h2>
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</h2>
<section class="post-excerpt" itemprop="description">
<p>{{ post.content | strip_html | truncatewords: 50 }}</p>
</section>
<section class="post-meta">
<div class="post-date">{{ post.date | date: "%B %-d, %Y" }}</div>
<div class="post-categories">
{% if post.categories.size > 0 %}in {% for cat in post.categories %}
{% if site.jekyll-archives %}
{{ cat | capitalize }}{% if forloop.last == false %}, {% endif %}
{% else %}
<span>{{ cat | capitalize }}</span>{% if forloop.last == false %}, {% endif %}
{% endif %}
{% endfor %}{% endif %}
</div>
</section>
</li>
{% if forloop.last == false %}
<hr>
{% endif %}
{% endfor %}
</ul>
<nav class="pagination" role="navigation">
<p>
{% if paginator.next_page %}
<a class="newer-posts" href="{{ site.baseurl }}/page{{paginator.next_page}}">
<span class="fa-stack fa-lg">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-angle-double-left fa-stack-1x fa-inverse"></i>
</span>
</a>
{% else %}
<span class="fa-stack fa-lg">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-angle-double-left fa-stack-1x fa-inverse"></i>
</span>
{% endif %}
<span class="page-number">Page {{ paginator.page }} of {{ paginator.total_pages }}</span>
{% if paginator.previous_page %}
{% if paginator.page == 2 %}
<a class="newer-posts" href="{% if site.baseurl %}{{ site.baseurl }}{% endif %}/">
<span class="fa-stack fa-lg">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-angle-double-right fa-stack-1x fa-inverse"></i>
</span>
</a>
{% else %}
<a class="newer-posts" href="{{ site.baseurl }}/page{{paginator.previous_page}}">
<span class="fa-stack fa-lg">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-angle-double-right fa-stack-1x fa-inverse"></i>
</span>
</a>
{% endif %}
{% else %}
<span class="fa-stack fa-lg">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-angle-double-right fa-stack-1x fa-inverse"></i>
</span>
{% endif %}
</p>
<p>
View All Posts by Category
</p>
</nav>
</div>
</div>
Open your config file, and set baseurl as /blog
baseurl: "/blog"
And use prepend:site.baseurl everywhere, just like you have used in above code
{{ site.baseurl }}/category/{{ cat }}

Resources