I am new to jekyll:
So far I had done what the tutorial has mentioned: This is what I have in _layout: post.html file:
---
layout: default
---
<div class="post">
<h1>{{ page.title }}</h1>
<span class="post-date">{{ page.date | date_to_string }}</span>
{{ content }}
</div>
<div class="related">
<h2>Related Posts</h2>
<ul class="related-posts">
{% for post in site.related_posts limit:3 %}
<li>
<h3>
<a href="{{ post.url }}">
{{ post.title }}
<small>{{ post.date | date_to_string }}</small>
</a>
</h3>
</li>
{% endfor %}
</ul>
</div>
and I use md file with a name 2014-01-01-myNewPost.md and I get the following error:
Generating... Invalid Date: '' is not a valid datetime.
Liquid Exception: exit in _layouts/post.html
I don't seem to see any issues but unable to really figure it out why its not working.
My problem was that for some reason I kept getting this error in the terminal when I ran "jekyll serve --incremental":
Liquid Exception: Invalid Date: 'nil' is not a valid datetime. in /_layouts/post.html
ERROR: YOUR SITE COULD NOT BE BUILT:
------------------------------------
Invalid Date: 'nil' is not a valid datetime.
and after much digging, it's because jekyll picks up posts of any kind in the root directory, even if they are in a whole different folder. I had my posts in "_posts" and my test posts in "old_posts".
Just having the "old_posts" directory at the root project level made this error occur. Make sure you don't have anything like that.
Most likely, you have moved the sample posts to another directory, e.g., examples. Jekyll finds the posts there and tries to process them, which leads to the encountered problem.
Add the examples folder to the exclude list in _config.yml, and Jekyll will start as expected.
Seems like you've a typo in the date variable in your post YAML matter. Check if your post date complies with this format YYYY-MM-DD HH:MM:SS
I've checked the post layout code posted above, its fine.
If nothing works, uninstall Jekyll and install the last stable release 1.2.1 by running these commands
~ $ gem uninstall jekyll
~ $ gem install jekyll --version(="1.2.1")
I had this happen and it turns out I had duplicated a file from my _posts directory by mistake with option-click and it was sitting in the root of my site. Would be nice if the processor would give a detailed description about the cause of the error in addition to the general error message.
Based on this GitHub issue it looks like Jekyll will complain if you label something as a post and then try to format the date if that thing doesn't have a date in the title or front matter. This doesn't happen if you reference {{ page.date }} without formatting it, so it must be some kind of nil error in the format function.
I just had this problem and I realized I'd labeled a bunch of static pages with layout: post in the front matter when the filename was example.md rather than 2016-01-01-example.md. I changed those files to layout: page and that solved the problem.
So at least on my site I have to make sure things without dates are pages and things with dates are posts. (I removed the date from my posts layout when I redesigned the site and just now got around to trying to put it back.)
Related
I'm using Go and package html/template. This is my code in mypage.tmpl:
<div class="col-sm-1">
<i class='fas fa-square companies-color' style="color: {{.Company.Color}}"></i>
</div>
But I get errors in VSCode:
property value expected css(css-property value expected)
and
at-rule or selector expected css(css-rule selector expected)
when I try {{ }} in style html.
I have found solution. Turn off html validate styles in setting's vscode
Hi I fixed this this by installing the Django extension in VsCode
I am attempting to setup a small blog using Jekyll. My work so far is as follows.
Setup a Github pages repository
Cloned the repo locally
Installed Ruby vs 2 and the sdk (windows)
Installed jekyll
'serve' the local website.
Validated that I could view my website localhost:4000
Everything worked fine however the liquid syntax is not working as expected. All syntax is output as plane text. I am not sure how to continue. This error happens both locally as well as on my github hosted page.
Here is my index.html file
<!DOCTYPE html>
<html lang="en-us">
<head>
{% include meta %}{{ site.time | date_to_xmlschema }}
</head>
<body>
{% include header.html %}
{% include header.html %}
{% include header.html %}
{% foo %}
{{ foo }}
<section class="main-content">
{% include footer.html %}
</section>
{% include scripts.html %}
</body>
</html>
My _config.yml has foo defined. =(
If you want Jekyll to process your page, you must add a Front matter to your page (see dedicated page in Jekyll documentation).
The minimum front matter is an empty one. That means that your page will use default configuration for layout, etc ..
---
# this is an empty front matter
---
Your content here
I am building an Octopress blog and I am implementing an alternative search implementation, lunr-search.
This requires an asset pipeline implementation for Jekyll.
My assets, javascripts and CSSs are compiled and combined correctly, but my images folder is not copied to the public folder.
EDIT with further info:
I have my assets under /source/_assets/javascripts, /source/_assets/stylesheets and /source/_assets/images.
The relevant part in _config.yml:
assets:
dirname: assets
baseurl: /assets/
sources:
- _assets/javascripts
- _assets/jwplayer
- _assets/stylesheets
- _assets/images
compress:
js:
css:
cachebust: hard
gzip: [ text/css, application/javascript ]
My compiled and combined assets are generated as expected under /public/assets, under which I can find the app.js and screen.css, however there is no images folder.
Thanks!!
Have you rewritten your source to use Jekyll-Assets to render image paths? In my experience, Jekyll-Assets needs to know you'll be using an asset before it will copy it to the output directory. It will know when you use a corresponding Liquid tag or filter.
According to the Jekyll-Assets readme, URLs for assets that are neither scripts nor stylesheets may be included with the following Liquid tag:
{% asset_path logo.png %}
Additionally, the following Liquid filter is available:
{{ 'logo.png' | asset_path }}: Returns resulting URL for logo.png
Both examples come from the URL above. So in this case the following two lines would be equivalent:
<img src="{% asset_path logo.png %}" alt="Logo">
<img src="{{ 'logo.png' | asset_path }}" alt="Logo">
If you are indeed already doing this, relevant HTML/Liquid source code may prove helpful.
This did the trick for me
{% img /images/logo.png %}
So I setup a Jekyll page, I created a few demo posts, got a navigation between them working and styled it to my liking and then went 'jekyll' in the root.
This generated a _site folder in my root. Awesome.
But when I open this folder in browser, and try to navigate between posts, it attempts to go to file:///2013/02/01/post-title.html instead of the actual location, which would be
file:///blablabla/_site/2013/02/01/post-title.html
I've been looking at Permalinks options in the yml-file, but I havent found a working solution yet.
I use:
<a href="{{page.previous.url}}" title="Previous Post: {{page.previous.title}}">
{{page.previous.title}}</a>
To navigate between posts, and:
{% for post in site.posts limit: 5 %}
{{ post.title }}
{% endfor %}
to link the posts from the main page.
From my config.yml:
baseurl: /
url: http://localhost:5000
source: .
destination: ./_site
permalink: /writing/
Taking any hints here!
Thanks
So what I did was:
In my _config.yml, I added this:
baseurl: /
url: http://some.link.he.re/~nameofdir/big_blog
And for assets like CSS/JS I simply used {{ site.url }} to pre-fix all my actual assets.:
<link href="{{ site.url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />
For navigation I did:
<a href="**{{site.url}}**{{page.previous.url}}" title="Previous Post:
{{page.previous.title}}"> {{page.previous.title}}</a>
In my post.html layout, I added: in the , I am not sure if this is necessary though, but for now it will linger.
For all static pages I added:
<li>Journal</li>
And finally, even though it's the same thing all over, for linking posts:
{{ post.title }}
So {{ site.url }} is the same as what you write in _config.yml at url: xxxx,
And if you're hosting your page on a server that has odd directory structure (like my university for example), you need to give url: the value of the actual root catalog, that means include the blog-folder-name as the last folder in the url. Then just prefix all your links, static or jekyll-generated by {{ site.url }} and you should be cool!
I am using jekyll to generate my website. I want to add a line number column to my code block. I searched google, and everyone told me to add a "linenos" option to the hightlight tag, but i doesn't work in my case:
{% highlight ruby linenos %}
def foo():
puts 'foo'
end
{% endhighlight %}
The highlight is working well, but the line numbers....
Could you help me with this? If you want to see the source css/html files, hit here.
Thanks!
Further checking:
the html generated for this section is :
<div class="highlight"><pre><code class="ruby">
<span class="k">def</span> <span class="nf">foo</span><span class="p">():</span>
<span class="nb">puts</span>
<span class="s1">'foo'</span>
<span class="k">end</span>
</code></pre></div>
I cloned your repo, generated the site, and check it out in the browser. Everything looks fine. (I like your layout!) That indicates to me that there's something funky in your setup. Is the code highlighting working for you? If not, you may not have Pygments set up correctly.
To install:
sudo apt-get install python-setuptools
sudo easy_install Pygments
To generate the css:
pygmentize -S default -f html > default.css
Make sure you have pygments: true in your _config.yml.
Make sure to place this stylesheet appropriately and include it in your default.html.
I see that you already have this stylesheet included in your page and your _config.yml seems fine, but for anybody else needing this answer, there it is.
If you generate the site with jekyll --no-auto do you see any errors in the output?
Let me know, and I'll be glad to try and help further. :)
Update: This is the HTML that's generated for me for the highlight test blog post you have.
<div class="highlight"><pre><code class="c"><span class="lineno">1</span> <span class="cp">#include <stdio.h></span>
<span class="lineno">2</span>
<span class="lineno">3</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
<span class="lineno">4</span> <span class="p">{</span>
<span class="lineno">5</span> <span class="n">printf</span><span class="p">(</span><span class="s">"Hello World!</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
<span class="lineno">6</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="lineno">7</span> <span class="p">}</span>
</code></pre>
</div>
I was just experiencing the same issue with pygments and jekyll. My markdown looked as
{% highlight c# linenos %}
//my code
{% endhighlight %}
and the resulting generated HTML
<div class="highlight">
<pre>
<code class="c">
...
</code>
</pre>
</div>
The highlighting was somehow odd and no line numbers have been added. Ultimately the problem was that Pygments apparently didn't recognize "c#" as a valid language, but instead I had to add "csharp".
(just in case someone else has this issue when setting it up)
I did the same thing. Although line number were showing the css wasn't being beautiful. The main reason was that bootstrap was conflicting with my style.css. Adding the following to the style.css resolved it.
.highlight pre {
background-color: transparent;
border: transparent;
color: inherit;
}