It's really a small things, but something I can't get out of my mind.
When running gh-pages locally with jekyll serve I get the "View on Github" button, but it's missing on the live page. Everything is up to date, and all files are the same both locally and live.
_config.yml
keyword: "NFT, Crypto, Art, Token, Promotions, New Artists"
url: "https://creepybits.github.io" # your host, for absolute URL
github_repo: "https://github.com/creepybits/creepybits.github.io.git" # you code repository
default.html
<header class="page-header" role="banner">
<h1 class="project-name">{{ page.title | default: site.title | default: site.github.repository_name }}</h1>
<h2 class="project-tagline">{{ page.description | default: site.description | default: site.github.project_tagline }}</h2>
{% if site.github.is_project_page %}
View on GitHub
{% endif %}
{% if site.show_downloads %}
Download .zip
Download .tar.gz
{% endif %}
</header>
I just can't see where the problem is.
Edit:
Gemfile
source "https://rubygems.org"
gem "github-pages", "~> 217", group: :jekyll_plugins
gem 'webrick', '~> 1.3', '>= 1.3.1'
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.12"
gem "jekyll-seo-tag", "~> 2.7.1"
gem "jekyll-textile-converter"
gem 'jekyll-opal', '~> 0.3.0'
gem "jekyll-github-metadata"
gem "jekyll-sitemap", "~> 1.4.0"
gem 'jekyll-theme-cayman', '~> 0.2.0'
gem 'jekyll-coffeescript', '~> 1.1', '>= 1.1.1'
end
platforms :mingw, :x64_mingw, :mswin, :jruby do
gem 'tzinfo', '~> 2.0', '>= 2.0.4'
gem 'tzinfo-data', '~> 1.2021', '>= 1.2021.1'
end
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
Command for launching website locally.
$ bundle exec jekyll serve
I found the issue in the header.
<header class="page-header" role="banner">
<h1 class="project-name">{{ page.title | default: site.title | default: site.github.repository_name }}</h1>
<h2 class="project-tagline">{{ page.description | default: site.description | default: site.github.project_tagline }}</h2>
{% if site.github.is_project_page %}
View on GitHub
{% endif %}
{% if site.show_downloads %}
Download .zip
Download .tar.gz
{% endif %}
</header>
Changed
{% if site.github.is_project_page %}
to
{% if site.github.is_user_page %}
And now it works like a charm.
Related
I have a strange problem where adding collections and collections_dir allows me to get one result where I can view the collection results on the ML Projects page that you can see in the sidebar of my website but it prevents any posts in _posts from rendering.
After doing some research I learned that posts is a collection by default, but I'm not sure how this helps me. I tried moving the _posts directory into the _projects directory, which is my collections_dir, but that does not work.
To replicate issue:
Clone the repo at https://github.com/luke-anglin/lukes_site
Build and serve the site, noting that posts do render
Go to _config.yml and remove the comments on line 26-29 which specify the collection and the collections_dir
Rebuild and see that the posts disappear, but the collection things work.
config.yml
# Dependencies
markdown: kramdown
# Permalinks
permalink: pretty
# Setup
title: Luke Anglin
tagline: Computer Science and Engineering Student
description: Software Engineering, DevOps, Data Science
url: http://localhost:4000/
baseurl: /
author:
name: Luke Anglin
# url: https://twitter.com/mdo
plugins:
- jekyll-paginate
paginate: 5
paginate_path: 'page:num'
# Custom vars
# Collections
# collections:
# - ml
# collections_dir: _projects
version: 2.1.0
github:
repo: https://github.com/luke-anglin/lukes_site
defaults:
- scope:
path: 'static/assets/media'
values:
image: true
index.html where the posts are supposed to be looped through
---
layout: default
title: Home
---
<div class="posts">
{% for post in paginator.posts %}
<div class="post">
<h1 class="post-title">
<a href="{{ post.url }}">
{{ post.title }}
</a>
</h1>
<span class="post-date">{{ post.date | date_to_string }}</span>
{{ post.content }}
</div>
{% endfor %}
</div>
<div class="pagination">
{% if paginator.next_page %}
<a class="pagination-item older" href="{{ site.baseurl }}page{{paginator.next_page}}">Older</a>
{% else %}
<span class="pagination-item older">Older</span>
{% endif %}
{% if paginator.previous_page %}
{% if paginator.page == 2 %}
<a class="pagination-item newer" href="{{ site.baseurl }}">Newer</a>
{% else %}
<a class="pagination-item newer" href="{{ site.baseurl }}page{{paginator.previous_page}}">Newer</a>
{% endif %}
{% else %}
<span class="pagination-item newer">Newer</span>
{% endif %}
</div>
Any other info can be found in the repo. Let me know if there are any other questions.
Try to remove the leading '_' from '_projects' directory. The 'collections_dir:' isn't allowed to have this character in the name of the target folder.
See: https://jekyllrb.com/docs/collections/
Particularly the red notice labeled 'Be sure to move drafts and posts into custom collections directory'. At the end it mentions 'Note that, the name of your collections directory cannot start with an underscore (_).'
Hope this helps.
I need to put Paging on my jekll site but when I try the posts disappear.
I use jekyll 3.8.6 and to include the jekyll-paginate plugin, I use the gem command 'github-pages', '170', group:: jekyll_plugins in the _config.yml file.
I want to paginate in index.html
code index.html :
---
layout: default
---
{% for post in paginator.posts %}
<h1>{{ post.title }}</h1>
<p class="author">
<span class="date">{{ post.date }}</span>
</p>
<div class="content">
{{ post.content }}
</div>
{% endfor %}
<!-- Pagination links -->
<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path }}" class="previous">
Previous
</a>
{% else %}
<span class="previous">Previous</span>
{% endif %}
<span class="page_number ">
Page: {{ paginator.page }} of {{ paginator.total_pages }}
</span>
{% if paginator.next_page %}
Next
{% else %}
<span class="next ">Next</span>
{% endif %}
</div>
code _config.yml
# Welcome to Jekyll!
#
# This config file is meant for settings that affect your whole blog, values
# which you are expected to set up once and rarely edit after that. If you find
# yourself editing this file very often, consider using Jekyll's data files
# feature for the data you need to update frequently.
#
# For technical reasons, this file is *NOT* reloaded automatically when you use
# 'bundle exec jekyll serve'. If you change this file, please restart the server process.
# Site settings
# These are used to personalize your new site. If you look in the HTML files,
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
# You can create any custom variable you would like, and they will be accessible
# in the templates via {{ site.myvariable }}.
title: <>Davi Luis</>
email: your-email#example.com
description: Experências no Mundo da Tecnologia
baseurl: "" # the subpath of your site, e.g. /blog
url: "www.daviluis.com.br" # the base hostname & protocol for your site, e.g. http://example.com
paginate: 5
paginate_path: "/blog/page:num/"
comments: true
gem 'github-pages', '170', group: :jekyll_plugins
# Build settings
theme: minima
# minima theme settings
show_excerpts: false # set to true to show excerpts on the homepage
# Minima date format
# refer to http://shopify.github.io/liquid/filters/date/ if you want to customize this
minima:
date_format: "%b %-d, %Y"
disqus:
shortname: https-www-daviluis-com-br
# If you want to link only specific pages in your header, uncomment
# this and add the path to the pages in order as they should show up
#header_pages:
# - about.html
# social links
#twitter_username: jekyllrb
github_username: daviluis321
#rss: rss
# dribbble_username: jekyll
# facebook_username: jekyll
# flickr_username: jekyll
# instagram_username: jekyll na
# linkedin_username: jekyll
# pinterest_username: jekyll
# youtube_username: jekyll
# googleplus_username: +jekyll
# Mastodon instances
# mastodon:
# - username: jekyll
# instance: example.com
# - username: jekyll2
# instance: example.com
# Exclude from processing.
# The following items will not be processed, by default. Create a custom list
# to override the default setting.
# exclude:
# - Gemfile
# - Gemfile.lock
# - node_modules
# - vendor/bundle/
# - vendor/cache/
# - vendor/gems/
# - vendor/ruby/
I index code node I try to print the posts and their page number.
In Minima theme's root folder. Change index.md file name to index.html Then paste pagination codes above it.
{% for post in paginator.posts %}
<h1>{{ post.title }}</h1>
<p class="author">
<span class="date">{{ post.date }}</span>
</p>
<div class="content">
{{ post.content }}
</div>
{% endfor %}
<!-- Pagination links -->
<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path }}" class="previous">
Previous
</a>
{% else %}
<span class="previous">Previous</span>
{% endif %}
<span class="page_number ">
Page: {{ paginator.page }} of {{ paginator.total_pages }}
</span>
{% if paginator.next_page %}
Next
{% else %}
<span class="next ">Next</span>
{% endif %}
</div>
Note: If this is not works, remove paginate_path: "/blog/page:num/" line in your config.yml file.
Pagination check list :
1- in _config.yml :
paginate: 5
paginate_path: "/blog/page:num/"
2- create an index.html (not markdown) first page in paginate_path. Here it's /blog/index.html
I'm using jekyll-sitemap plugin for Jekyll.
Is there a way to exclude .html files within the assets folder?
Some of them contain some HTML examples and I end up having things like the following in my sitemaps.xml, which doesn't make sense:
<url>
<loc>https://example.com/blog/assets/vanilla-lazyload/demos/with_picture.html</loc>
<lastmod>2017-11-18T15:05:22+01:00</lastmod>
</url>
Where with_picture.html is a demo file of a Javascript library, that comes with it when using npm install (and I can't be bother to remove those every time for every library)
According to the docs, using sitemap: false in our front matter should solve it, but it doesn't seem to be working at all.
Because I do not have any front matter in those vendor files, I'm using the Jekyll's Front Matter defaults method to do so, but without success.
# in my _config.yml
defaults:
- scope:
path: 'assets/'
values:
sitemap: false
I also tried the following path without luck:
path: "assets"
Might it be that path: 'assets' wont' take into account subfolders?
If your Jekyll version is v3.7.2 or higher and your jekyll-sitemap version is v1.2.0 or higher, this should work:
defaults:
-
scope:
path: 'assets/**'
values:
sitemap: false
The ** will match any file in the assets directory or in any of its subdirectories.
Here's the relevant section in the docs.
You can easily create your own sitemap without the plugin: Create a file called ‘sitemap.xml’ in your main jekyll folder, as in next to _post, _pages, and _includes.
All the file needs to contain is the following:
---
layout: null
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for post in site.posts %}
<url>
<loc>{{ site.url }}{{ post.url }}</loc>
{% if post.lastmod == null %}
<lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
{% else %}
<lastmod>{{ post.lastmod | date_to_xmlschema }}</lastmod>
{% endif %}
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
{% endfor %}
{% for page in site.pages %}
{% if page.sitemap != null and page.sitemap != empty %}
<url>
<loc>{{ site.url }}{{ page.url }}</loc>
<lastmod>{{ page.sitemap.lastmod | date_to_xmlschema }}</lastmod>
<changefreq>{{ page.sitemap.changefreq }}</changefreq>
<priority>{{ page.sitemap.priority }}</priority>
</url>
{% endif %}
{% endfor %}
</urlset>
In your _config.yml file, add :
exclude :
- assets/vanilla-lazyload/demos
Jekyll does not seem to use the markdown code style blocks that github uses even though they're from the same organization.
Seems like jekyll 3 is requiring the usage of {%highlight ruby %}
is there a canonical way to do clean syntax highlighting with jekyll 3?
looks like
{% highlight ruby %}
{% raw %}
{% for template in site.templates %}
...
{% endfor %}
{% endhighlight %}
and
{% codeblock ruby %}
{% raw %}
{% for template in site.templates %}
...
{% endfor %}
{% endcodeblock %}
do the same thing!
and backticks are not converting into code blocks
If you want to use Github Flavored Markdown you can add this to your _config.yml file :
kramdown:
# use Github Flavored Markdown
input: GFM
What version of Jekyll are you using?
Jekyll uses GFM-version of Kramdown since v3.1.0
From the codebase of v3.1.0:
'kramdown' => {
'auto_ids' => true,
'toc_levels' => '1..6',
'entity_output' => 'as_char',
'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo',
'input' => "GFM",
'hard_wrap' => false,
'footnote_nr' => 1
I am attempting to template yum .repo files. We have multiple internal and external yum repos that the various hosts we manage may or may not use.
I want to be able to specify any number of repos and what .repo file they will be templated in. It makes sense to group these repos in the same .repo file where they have a common purpose (e.g. all centos repos)
I am unable to determine how to combine ansible, yaml and j2 to achieve this. I have tried using the ansible 'with_items', 'with_subelements' and 'with_dict' unsuccessfully.
YAML data
yum_repo_files:
- centos:
- name: base
baseurl: http://mirror/base
- name: updates
baseurl: http://mirror/updates
- epel:
- name: epel
baseurl: http://mirror/epel
Ansible task
- name: create .repo files
template: src=yumrepos.j2 dest="/etc/yum.repos.d/{{ item }}.repo"
with_items: yum_repo_files
j2 template
{% for repofile in yum_repo_files.X %} {# X being the relative index for the current repofile, e.g. centos = 0 and epel = 1 #}
{% for repo in repofile %}
name={{ repo.name }}
baseurl={{ repo.baseurl }}
{% endfor %}
{% endfor %}
When you use with_items with the template module the special variable item will be passed into your jinja template.
Try this:
{% for repofile in item %}
{% for repo in repofile %}
name={{ repo.name }}
baseurl={{ repo.baseurl }}
{% endfor %}
{% endfor %}
user24364's answer helped solve half the issue, I then used some python methods to get the correct data out of the lists and dicts.
Giving the full filename 'centos.repo' rather than 'centos' simplified the logic (and aligned better with the logic for other tasks):
yum_repo_files:
- centos.repo:
- name: base
baseurl: http://mirror/base
- name: updates
baseurl: http://mirror/updates
- epel.repo:
- name: epel
baseurl: http://mirror/epel
The .iterkeys() and .next() methods are used on items to get the repo filenames out of the list of dicts:
- name: create .repo files
template: src=yumrepos.j2 dest="/etc/yum.repos.d/{{item.iterkeys().next()}}"
with_items: yum_repo_files
The .itervalues() method is used to get the list of dicts containing all the keys/values for each given repo:
{% for repofile in item.itervalues() %}
{% for repo in repofile %}
[{{repo.repo}}]
name={{ repo.name }}
baseurl={{ repo.baseurl }}
{% endfor %}
{% endfor %}
I also added some other tasks to clean up unmanaged files, etc. Once I've sanitised the code, I'll post it to the ansible galaxy as nobody else seems to have shared such a role.
Your files would be named as: *.repo.j2; then, you can use fileglob:
- name: create x template
- template: src={{ item }} dest=/tmp/{{ item | basename | regex_replace('.j2','') }}
- with_fileglob:
- files/*.j2
Reference:
https://serverfault.com/questions/578544/deploying-a-folder-of-template-files-using-ansible