Question
What's the right way to get Hugo's version number in locale files i18n/*.yaml under Hugo v0.55?
Background
I'm using Hugo with the theme Beautiful Hugo, which included the following deprecated syntax since v0.55:
.URL
.Hugo
.RSSLink
#2 is used in locale files i18n/*yaml to get Hugo's version number {{ .Hugo.Version }}, but this is deprecated.
As a result, my terminal showed messages similar to this when running hugo server.
Building sites … WARN 2019/04/09 10:14:55 Page's .URL is deprecated and will be removed in a future release. Use .Permalink or .RelPermalink. If what you want is the front matter URL value, use .Params.url.
WARN 2019/04/09 10:14:55 Page's .Hugo is deprecated and will be removed in a future release. Use the global hugo function.
WARN 2019/04/09 10:14:55 Page's .RSSLink is deprecated and will be removed in a future release. Use the Output Format's link, e.g. something like:
{{ with .OutputFormats.Get "RSS" }}{{ . RelPermalink }}{{ end }}.
Source: https://gist.github.com/chris-short/78582dc32f877d65eb388f832d2c1dfa
Goal
How to suppress warning #2 .Hugo? (I've already done #1 & #3).
Attempt
#peaceiris on Qiita suggests changing {{ .Hugo.Generator }} to {{ hugo.Generator }}.
Image source: linked blog post
I applied this to locales i18n/*.yaml. i.e. I replaced {{ .Hugo.Version }} with {{ hugo.Version }} in those YAML files. However, I got a function "hugo" not defined error. I tested {{ hugo.Version }} in a Go-HTML template file, and it's OK.
Error: "/home/vin100/beautifulhugo/i18n/zh-TW.yaml:1:1": failed to load translations: unable to parse translation #14 because template: 由 Hugo v{{ hugo.Version }} 提供 • 主題 Beautiful Hugo 移植自 Beautiful Jekyll:1: function "hugo" not defined
map[id:poweredBy translation:由 Hugo v{{ hugo.Version }} 提供 • 主題 Beautiful Hugo 移植自 Beautiful Jekyll]
Thanks to #bep on Hugo Discourse, I've found the soluton! Simply use {{ .Site.Hugo.Version }}.
Reference: #bep's answer on Hugo Discourse
Related
I want to run a DBT Snapshot and am following a near-identical template to the one outlined in the documentation. However, I get the error when I run dbt snpashot
Compilation Error in model test_snapshot (.../project_folder/snapshots/test_snapshot.sql)
Encountered unknown tag 'snapshot'.
line 1
{% snapshot test_snapshot %}
Below is the code I am attempting to compile.
{% snapshot test_snapshot %}
{{
config(
strategy='check',
unique_key='id',
target_schema='snapshots',
check_cols= 'all'
)
}}
select
*
from {{ ref('modle_in_sample_folder') }}
{% endsnapshot %}
The order of the snapshot folder and ref file is .../project_folder/snapshots/test_snapshot.sql and .../project_folder/intermediate/model_in_sample_folder.sql
The problem was the location of my Snapshot folder. Once I moved it out of my models project folder, and up to one level in the folder hierarchy, I was able to run it successfully.
When using Jekyll data files I would like to store a formatted description, primarily to that I can have links in it. It works with HTML.
- name: Project name
description: >
I want to include a link
That renders properly in the generated page when included with {{ project.description }}.
Can I use markdown instead of HTML? I would prefer to do this:
- name: Project name
description: >
I want to include a [link](http://foobar.com)
Turns out Liquid supports filters, but doesn't have one for processing markdown. Thankfully Jekyll adds it's own set of handy filters which includes markdownify so now I can do this:
{{ project.description | markdownify }}
I want to write a Jekyll plugin that modifies the site object. The site object is available throughout the Jekyll build process. In Jekyll, the most direct way to add an attribute to it is to define it in the _config.yml file. That works in some cases, but I need to take it a step further.
The reason I am asking this question is because I need to do more than I can do in the context of a YAML file. I want to add a method to the site object. I assumed I'd only need to add the method to the Site class, but it isn't working.
Non-working plugin:
module Jekyll
class Site
def foo
"foo"
end
end
end
I assumed from reading the Jekyll source and from how Ruby classes can be extended that the site object in Jekyll would have the new foo method, but it doesn't. For reference, here is the Site Class in the Jekyll source code.
This is as much a question required because of my poor ability to read the RUby code that Jekyll is constructed in as it is a question about Jekyll itself.
Maybe you can do it without a plugin. Inspired by Jekyll Bootstrap you can craft a global variable to target your assets folder.
_config.yml
# can be '' or '/repositoryName'
baseurl: /repositoryName
ASSET_PATH : /assets
_layouts/default.html
---
front mater ...
---
{% capture ASSET_PATH %}{{ site.baseurl }}{{ ASSET_PATH }}{% endcapture %}
Then call assets from post or page :
<link href="{{ ASSET_PATH }}/bootstrap/css/bootstrap.min.css" rel="stylesheet">
or
![img title]({{ ASSET_PATH }}/img/toto.jpg)
I have Jekyll 2.4.0 and Ruby 2.0.09576 installed.
I am working along with Travis from YouTube channel 'DevTips' and using all of his files/information to compile his 'Artist' project site. Last week I successfully served the project site via Ruby/Jekyll serve from source folder. Today, I tried the same process and the site would not compile. I am using same localhost:8000, that is verified and worked last week. I am running Win7 64bit and followed advice to run UTF-8 encoding command: chcp 65001.
No files have changed in the portfolio folder on my PC, NO windows updates or other software installed. The other thing on jekyllrb.com/windows/ says is to add a line of code for 'Auto-regeneration' to the 'Gemfile'...OK, it does not say where this 'Gemfile' is to edit...is it here?: C:.../RubyDevKit/bin/gem.windows batch file?
I am stumped as to why the project files compiled and displayed just fine last week and today it does not work, NO connection can be made to localhost:8000...so no site generated. I also tried to view view site via Prepros, using their 'Open Live Preview' and that generates a site on localhost:8001 displaying only this text: --- --- {% include header.html %} {% include about.html %} {% include work.html %} {% include clients.html %} {% include contact.html %} {% include form.html %} {% include footer.html %}
I've tried other localhost addresses...8000 through 8005.
Any ideas?
Thank you!
Mark
Have you changed the localhost adress?
Default localhost for jekyll is 4000.
Also Prepros live preview will not work in your jekyll folder, because the acutal site is
rendered within the _site-folder. This folder is what jekyll serve generates.
So can you maybe access the site over localhost:4000 and/or is the _site-folder there? Or does jekyll just not work at all?
SOLVED! I will be buying 'Mixture' front end developer framework software! Enough of the bugs and wasted time coming mostly from lame Windows software issues!
CHEERS!
Mark
Do you have the latest version of Python Installed? I had the same issue but after installing python's latest update (2.7.9) the issue was resolved.
I have problem that categories are not url encoded when I use german words with Umlauts (e.g. ä, ü). I tried the cgi_escape that Liquid seems to offer, but success with the following code:
<strong>Kategorien</strong><br/>
{% for category in site.categories do %}
<small>{{ category[0] }} <br/>
</small>
{% endfor %}
Can anyone help?
Using cgi_escape doesn't work correctly for categories with spaces. Links were generated as /category/the+category instead of /category/the%20category.
The solution I ended up using was from this blog post:
# _plugins/url_encode.rb
require 'liquid'
require 'uri'
# Percent encoding for URI conforming to RFC 3986.
# Ref: http://tools.ietf.org/html/rfc3986#page-12
module URLEncoding
def url_encode(url)
return URI.escape(url, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
end
end
Liquid::Template.register_filter(URLEncoding)
A plus is a literal plus anywhere but in the query portion of the URL, where it represents a space. Good URL encoding reference (archive.org mirror).
This can then be used in a layout or anywhere else:
<a href="{{ site.category_dir }}/{{ category | url_encode }}">
#Peterb, have you upgraded to the latest version of Jekyll? The current 1.0x version supports UTF-8 and handles URLs like this much better.
You can install the latest version by running this from your Terminal command line:
$ [sudo] gem install jekyll --pre
This GitHub Issue post will shed more light on the issue:
https://github.com/mojombo/jekyll/issues/960