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
Related
QUERY:
$recent_posts = Blog::join("categories",'categories.id', '=', 'blogs.category_id')
->where('categories.status', 1)
->orderBy('blogs.id', 'desc')
->take(3)
->get();
Both tables had a created_at column.
At frontend im using this to retrieve the data:
<div class="row justify-content-center">
#foreach ($recent_posts as $recent_post)
<div class="col-md-6 col-lg-4 latest-blog-resp">
<div class="blog-item">
<div class="blog-img">
<a href="{{ url('blog/'.$recent_post->slug) }}">
#if ($recent_post->blog_image == '')
<img src="{{ asset('fibonacci/adminpanel/assets/img/dummy/no_image.jpg') }}" class="img-fluid round-item" alt="blog image">
#else
<img src="{{ asset('fibonacci/adminpanel/assets/img/blog/thumbnail1/'.$recent_post->blog_image) }}" class="img-fluid round-item" alt="blog image">
#endif
</a>
</div>
<div class="blog-inner">
<div class="blog-meta">
<span class="mr-2">
<i class="mdi mdi-calendar-account-outline"></i>{{ __('frontend.by_admin') }}
</span>
<span>
<i class="mdi mdi-calendar-range"></i>{{Carbon\Carbon::parse($recent_post->created_at)->isoFormat('MMMM')}} {{Carbon\Carbon::parse($recent_post->created_at)->isoFormat('DD')}}
</span>
</div>
<h5 class="blog-title">
{{ $recent_post->title }}
</h5>
<p class="blog-desc">{{ $recent_post->short_description }}</p>
<a href="{{ url('blog/'.$recent_post->slug) }}" class="blog-more-link">
{{ __('frontend.read_more') }} <i class="fa fa-angle-right ml-2"></i>
</a>
</div>
</div>
</div>
#endforeach
#if (count($recent_posts) === 3)
<div class="col-12 text-center margin-top-30">
<div class="btn-group">
<a href="{{ url('blog') }}" class="default-button">
{{ __('frontend.view_all') }}
</a>
</div>
</div>
#endif
</div>
THE PROBLEM:
$recent_post->created_at returns the category table creation (created_at) date but we expect to receive the blog table result as created_as (like a post creation data).
Thanks in advance!
Specify your fields in a select clause.
$recent_posts = Blog::select(
'blogs.slug',
'blogs.blog_image',
'blogs.title',
'blogs.short_description',
'blogs.created_at'
)
->join('categories', 'categories.id', 'blogs.category_id')
->where('categories.status', 1)
->orderByDesc('blogs.id')
->take(3)
->get();
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>
So I have this simple admin toolbar:
<div class="admin-toolbar {{ $class ?? '' }}">
<i class="fas fa-user-shield"></i>
{{ $buttons }}
</div>
And I use it as such:
#admintoolbar
#slot('buttons')
<a href="/snippet/destroy/{{ $snippet->id }}">
<i class="margin-left(8px) far fa-trash-alt"></i>
</a>
#endslot
#endadmintoolbar
Surprisingly, I get Undefined variable: buttons at line {{ $buttons }}
I have a list of articles in my data and one of the fields is a link to an image. I'm using jeykll-assets, and I would like to load the images using the asset_path. However, the following isn't working:
{% for article in site.data.press %}
<div class="press-item">
<div class="press-image">
<div class="centerit"></div>
<a href="{{ article.url }}" target="_blank">
<img src="{% asset_path article.logo %}" />
</a>
</div>
<div class="press-excerpt">
<a href="{{ article.url }}" target="_blank">
<p>{{ article.title }}</p>
</a>
</div>
<div class="date">{{ article.date }}</div>
</div>
{% endfor %}
Specifically <img src="{% asset_path article.logo %}" /> because it doesn't load article.logo dynamically. What's the correct way to do this?
Use brackets like this : <img src="{% asset_path {{ article.logo }} %}" />
See https://github.com/jekyll/jekyll-assets#liquid-variables
I'm building a website with Volt 0.9 and I'm trying to customize my main.html regarding navigation.
Well, there is and if binding in the :Nav section to add a class. The problem is that I want to add another class with another if binding. I've tried to add a second if binding, but no luck, the are not rendered when I'm using a second if binding.
How can I do that ?
Here's the file :
<:Title>
{{ view main_path, "title", {controller_group: 'main'} }}
<:Body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<ul class="nav navbar-nav pull-left">
<:nav href="/">Hammicus</:nav>
<:nav href="/tv">HammicusTV</:nav>
<:nav href="/radio">HammicusRadio</:nav>
<:nav href="/contact">Contact</:nav>
</ul>
<:volt:notices />
{{ view main_path, 'body', {controller_group: 'main'} }}
</div>
</nav>
<footer class="footer">
<p>© Hammicus {{ Time.now.year }}</p>
</footer>
<:Nav>
<li class="{{ if active_tab? }}active{{ end }} {{ if attrs.href == "/" }}brand{{ end }}">
{{ yield }}
</li>
The problem seems to be the double quotes around the "/"
Replace them with single quotes (so they are properly nested) and it should work.
ie
class="{{ if active_tab? }}active{{ end }} {{ if attrs.href == '/' }}brand{{ end }}"