Creating two blogs on same website (Jekyll GitHub) without altering layout/formatting
You've removed the posts
collection from your _config.yml
which was setting the default feature_image
for all posts. Unless you add that back in or include the overrides in each individual post it will not display the header (it may or may not also affect the rest of the styles):
collections:
media:
title: Media # Needed for Siteleaf
output: true
description: "Recent discussions with the media." # The post list page content
feature_text: |
Sharing our motivations and
opinions with the media.
feature_image: "https://picsum.photos/2560/600?image=866"
You're not actually using a media collection in either blog/index.html
nor media/index.html
, you're using the post.categories
for filtering in the end, which will still causes some weird pagination once you start getting things rolling.
You may want to look at using the separate collections and then pre-building your site using paginator v2 (https://github.com/sverrirs/jekyll-paginate-v2/blob/master/README-GENERATOR.md) which will allow for pagination of different collections.
Edit 2020-01-23
Taking a new look at your repository, you still only have one (posts) collection. Therefore the logic for reading feature_*
is being shared. If you look at the include site_feature.html
you can see how the feature_image is being parsed out of the collections.
{% assign collectiondata = site.collections | where: "label", page.collectionpage | first %}
Which in your case is why Blog and Media both have the second image ?image=213
. Your blog.html
and media.html
still have the front matter collectionpage: post
.
I still think you're going down a slippery slope which will result in things not working exactly as you want them once you get more and more posts by doing it this way.
Is there any way to roll two paginated blogs into one Jekyll site, hosted in a single GitHub Pages repo?
Use any custom Plugin/Gem with your GitHub Pages hosted Jekyll blog
Here is how you CAN use any custom plugin on a GitHub Pages hosted website. I use this on my own blog so I'm 100% certain that it works. The basic idea is that you use TravisCI to build your custom Jekyll site on a staging
branch and then push it automatically to your GitHubPages master
branch that serves your website. Here comes the quick walkthrough:
a) you configure GitHub Pages to host from the docs
folder of your master
branch
b) you add and configure a staging
branch to be the default branch of your repo, there is where you do all your local work, releases work through setting a git tag on this branch
c) you use _config.yml
file to set your destination
directory to docs
# _config.yml
destination: docs
d) to avoid build issues with Travis CI you can add Gemfile.lock
to your .gitignore
file and the docs
folder to your local .git/info/exclude
since you don't want to push them anymore. To exclude the docs
folder from a local push is optional, but for me that works best. You also may need to delete the Gemfile.lock
first and then let Travis CI pick the fitting versions for the selected Docker OS, otherwise you can run into version conflicts which can be pretty hard to fix.
e) to deploy with Travis CI into production
a.k.a. your live site you add a .travis.yml
file alike :
language: ruby
rvm:
- 2.6.3
install:
- bundle install
script:
- JEKYLL_ENV="production" bundle exec jekyll build
deploy:
provider: script
script: bash script/deploy.sh
skip_cleanup: true
on:
tags: true
branch: staging
branches:
only:
- staging
- /\d+\.\d+(\.\d+)?(-\S*)?$/
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
- secure: TRAVIS_SECRET_KEY_FOR_GITHUB_CREDENTIALS
sudo: false
cache: bundler
notifications:
email: false
g) script/deploy.sh
looks somewhat like this:
#!/usr/bin/env bash
bundle install
JEKYLL_ENV="production" bundle exec jekyll build
git status
git add .
git commit -m"[skip travis] Automated build"
git remote set-url origin https://USERNAME:$PSW@github.com/YOUR_GIT_USER/YOUR_REPO.git
git push origin HEAD:master --force
e) to get your encrypted TRAVIS_SECRET_KEY_FOR_GITHUB_CREDENTIALS
in .travis.yml
with the used $PSW
variable used in the deploy script, just follow the Encryption Key Doc
Once this configuration is done, you can use any Gem the same way as on localhost since the building part is not done by GitHub anymore but TravisCI.
Conclusion
You just work on staging
and only let Travis CI push to your master branch. You use tags in the form 1.0.0
to deploy. All you need to do now is to add jekyll-paginate-multiple
to your Gemfile
and _config.yml
and you are ready.
If anyone is interested in more details for those step, have a look at this Blog Post detailing the issue
Posts not showing correctly on jekyll (multiple site) blog -- only post code
blog.md is a markdown file.
In markdown a four space indentation represents code or preformatted text.
Kramdown will wrap this code in <pre>
tag, resulting on what you actualy see on your site.
If you remove your indentation (or keep it under 4 spaces), your problem is solved.
{% for post in site.posts %}
{% if post.categories contains 'blog' %}
<div class="post">
<h3 class="title"><a href="{{ post.url }}">{{ post.title }}</a></h3>
<p class="meta">Date: {{ post.date }}</p>
<div class="entry">
{{ post.content | strip_html | truncatewords: 100 }}
</div>
</div>
{% endif %}
{% endfor %}
Single Index Blog Post for Multiple Series Posts in Jekyll
In your index.html, {% if post.series == nil %}
simply bares posts containing a series: someserie
front matter variable to be printed.
For the second problem (note that on SO, you are supposed to ask one question at a time) :
- Umbrella post always have
series_slug: "My serie slug"
in front
matter. - Serie's posts always have
series: "My serie slug"
in front
matter, and this must be strictly equal to umbrella pageseries_slug
. (eg : you have a post with published: false and series: "SQL Zoology" that will not appear inSQL Zoo
serie if you publish it.)
In _layouts/post.html remove {% include series.html %}
.
In _includes/post-series.html replace all your code by the following :
{% comment %} #### On an umbrella page {% endcomment %}
{% if page.series_slug != nil %}
{% assign key = page.series_slug %}
{% assign title = page.title %}
{% assign url = page.url %}
{% assign sentence = "All posts in this serie :" %}
{% endif %}
{% comment %} #### On a serie page {% endcomment %}
{% if page.series != nil %}
{% assign key = page.series %}
{% assign umbrella_page = site.posts | where: 'series_slug', key | first %}
{% assign title = umbrella_page.title %}
{% assign url = umbrella_page.url %}
{% assign series_posts = site.posts | where: "series", key %}
{% for post in series_posts %}
{% if post.url == page.url %}
{% assign idx = forloop.index %}
{% endif %}
{% endfor %}
{% capture sentence %}
This article is <strong>Part {{ idx }}</strong> in a <strong>{{ series_posts.size }}-Part</strong> in <a href="{{ site.baseurl }}{{ url }}">{{ title }} serie</a>
{% endcapture %}
{% endif %}
{% if page.series_slug != nil or page.series != nil %}
{% assign series_posts = site.posts | where: "series", key %}
<hr />
<div class="panel">
<div class="panel-body">
{% if page.series_slug != nil %}
{% assign key = page.series_slug %}
{% assign title = page.title %}
{% assign url = page.url %}
{% endif %}
<h4>{{ sentence }}</h4>
<ul id="post-series-list">
{% for post in series_posts %}
<li>
{% if page.url == post.url %}
This post : {{ post.title }} - part {{ forloop.index }}
{% else %}
<a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }} - part {{ forloop.index }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
Two jekyll blogs on the same GitHub page
alkamid.github.io
is a user repository, github pages looks for file to publish in master
branch. Any additionnal gh-pages
branch will be ignored.
To achieve your goal : just create a travel
repository and simply push code for you second blog in gh-pages
branch.
See github pages documentation about this particular problem.
Adding Jekyll (only the blog portion) to my website
My question is how would I be able to add the Jekyll blog portion to my website which already has a layout and theme?
With Jekyll you can do that very easily. Just follow these steps:
- You can leave the static html files in the root (and subdirectories). They will not collide with Jekyll.
- Create an empty _config.yml file in the root.
- Create a layout your posts overview and for your single post layout in a _layouts folder in the root.
- Create a _posts folder in the root and add your first file/blog post in this format: 2018-12-31-happy-new-year.md
- Make sure the blog post (.md file) looks like this:
---
title: Happy New Year
---
Your content
- Now run 'jekyll serve' from the command line in the root of your website. Jekyll (if installed correctly) will create a _site folder with the generated website (in plain HTML).
That is all! More info about setting up Jekyll can be found at the Jekyll website.
Jekyll multiple custom repeatable content
I figured out the problem. First one is the folder structure. Simply keep all the postfiles in the _posts/ file in the root directory. The second one is the capitalization of the category name in your liquid tag. Although there are no semantic differences between JOBS and jobs, when used in liquid arguments, they act in a weird way. So try to keep them in lower case. Simply replace the line
{% for post in site.categories.JOBS %}
with this
{% for post in site.categories.jobs %}
This won't solve your problem right away. Jekyll expects you to wrap your posts YAML matter between --- 3 dashes. So you've to use the following format for you post markdown and everything will work:
---
title: test
category: jobs
length: April 2010 – April 2012
position: Junior Developer
---
Content to be displayed
Related Topics
In Ruby, Should I Use ||= or If Defined? for Memoization
Deleting While Iterating in Ruby
Counting Days Excluding Weekends
Most Efficient Way to Calculate Hamming Distance in Ruby
How to Get the Current Route in Rails
How to Run Phantomjs on Heroku
Devise Skip_Confirmation! Fails to Avoid to Send the Confirmation Instructions
Rvm Install: Ruby Installation Error
Trouble Resizing the Default Image with Paperclip
How to Use Ruby Metaprogramming to Add Callbacks to a Rails Model
How to Get a HTML Table Row with Capybara
Scientific Programming with Ruby
In Ruby, How to I Control the Order in Which Test::Unit Tests Are Run
What Is a Robust Installation Process for Nokogiri (On Ubuntu)
How to Configure Mongomapper and Activerecord in Same Ruby Rails Project