Adding Jekyll (only the blog portion) to my website - jekyll

I wish to add Jekyll (only the blog portion) to my already existing website. I currently have this repo on my Github (https://github.com/TonyHoanTrinh/TonyHoanTrinh.github.io). Where I currently have a folder for Images. An index.html, main.js and style.css files.
My question is how would I be able to add the Jekyll blog portion to my website which already has a layout and theme?
I've been looking at several Jekyll tutorials but they have it start the project from the beginning using a theme and etc. I already have a website with a layout and styling from myself. But I wish to add the Jekyll blog portion to my website. I noticed an existing post on doing this but its from the context of config.yml and other files which I'm not sure pertains to my project.

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.

Related

Jekyll not rendering templated page

I'm running Jekyll 4.0.0 and Bundler version 1.17.2. As this time of posting, it is the latest version of both Jekyll and Bundler.
I have a template called default, which I use to standardize the appearance of navbar, footer, and location of content being displayed.
The directory structure of my website is as follows:
_data: a folder of yml data files for listings of open source projects I worked on
_includes: a folder containing footer and navbar html files
_layouts: a folder containing liquid templated layout files. This is where "default.html" layout file is located.
_posts: a directory of blog posts that I want rendered by Jekyll
CNAME img: image files index.html credits.html
lib: a directory that hosts all of my CSS, fonts, JavaScript files
logo.ico
opensource: a folder containing layouts related to open source
What I'm having trouble with is adding the credits.html page. Using index.html as a template (since index.html renders perfectly), I have the following meta data pasted at the top of credits.html:
---
title: <my name>
layout: default
description: <my description>
---
Under that are all the HTML related to the contents section of the page. When I test my website locally and on github pages, I noticed Jekyll gives me a 404 not found error. I know this is not true because the moment I put credits.html inside another folder (ie: /credits/credits.html) the page renders fine with the url localhost:4000/credits/credits.
I do have permalink set as "pretty" for the entire static website.
Does anyone know why I can't seem to render the credits page? The index page seems to work just fine. I've tried digging through the documentation, but I can't seem to figure out what is affecting that one page.
** EDIT **
I discovered that if I go to localhost:4000/credits/, the page renders perfectly. This is definitely a permalink issue. Can someone point me in the right direction of how I can fix this issue?
I solved the issue!
The reason is because I had permalink enabled in the global configuration file "_config.yml". Inside that file, I had permalink: pretty set. This is why localhost:4000/credits/ worked but not localhost:4000/credits.html.
To resolve this issue, I removed that setting from the global config file. I also realized at the same time that permalink was not necessary for my use case.
For anyone who is in this situation but requires permalink for other sections of your website, set permalink per template file via front matter instead.

Jekyll does not create html page from markdown file

I'm new to Jekyll and build a webpage using the TeXt Theme. I downloaded all files and created a local Jekyll website which runs successfully. The project folder contains the folders
_data
_includes
_layouts
_posts
_sass
_site
assets
docker
docs
screenshots
test
tools
The rest of the files in the folder are _config.yml, index.html, etc.
Now let's say I want to create a new page "Bio" that appears as an entry or name in the navigation bar at the top of the website like "about" or "archive".
I create a .md-file in the main project folder (i.e. where index.html lies) and specify in the front matter the layout - in the case of TeXt it is
layout: page
Also, in the _data folder I open the navigation.yml and append under "header" a new title called "Bio", i.e.
header:
title: Bio
url: /Bio.html
This is completely analogue to the about-page that is in the navigation bar and works properly.
But when I do it like this with Bio I get a 404 error and Jekyll is not able to find the site.
I searched all folders of the project and found that Jekyll does not create the necessary.html-file Bio.html on the basis of Bio.md. It just moves Bio.md into _site.
Hence, the url given in the navigation.yml cannot be found and I get the error. How do I get Jekyll to create the Bio.html?
If Bio.md is just copied, that means that Jekyll thinks it's a static file.
You're certainly missing a correct Front matter.
Your Bio.md should look like :
---
layout: page
title: Bio
---
## Content here
...
If problem persists, please add a repository url to help debug.
I figured out the answer myself. It is the notorious UTF-8 BOM issue with Jekyll. The file Bio.md was written in Notepad which uses BOM by default. Using ANSI instead solved the problem entirely without changing anything at the previous front matter.

Can you change the root directory in jekyll

I've been trying to change the root directory of my jekyll site to another folder but I can't seem to find a way to do this and was wondering if it's possible?
What I want is for all of my html pages to be in a folder named _pages, and for my website to load index.html from this folder. Currently I can only get this working by changing the baseurl and accessing the website by www.domain.com/pages/index.hmtl. Can I have it so the html files remain in this folder, and have jekyll render the site so that I can access index.html from www.domain.com/ ?
Thank you
In your _config.yml file you'll need to include the directory where your HTML pages live like this:
include: [_pages]
In your _pages/index.html file include a permalink in the frontmatter like this:
---
permalink: /
---
Run your Jekyll build command again. If I understand your question correctly, this will output your homepage without needing to have or adjust your baseurl.

Why site.baseurl doesn't work on Jekyll?

i have been trying to create jekyll site and host on git-pages. Localy everything works fine. But on github-pages works only first pages and 10 newest blog post.
But after going to any of other pages like "Blogas" or "Straipniai" every link starts with 'localhost:4000' and naturaly breaks css, javascript...
And i am not sure where is problem, because everything is same even if i make change in /_includes/header.html site.url to site.baseurl.
Here is git-hub
And site
I think the problem is that you somehow have both a .md and an .html version of the same pages. The .html version you built locally and GH is preferring it. it has localhost in the urls so it won't work. Try deleting the .html files in those sub folders and see what happens. For example, delete the index.html file from invisibleghostt.github.io/blogas/ and see if that page is fixed.
No idea how you got those files in there, they should not be there.
Look, there are a few things you'd better fix on your _config.yml:
url: "http://codas.lt" # add the site url
gems: # remove `jekyll` from gems
- jekyll-sitemap
- jekyll-gist
- octopress
include: [".htaccess"] # remove this line (GitHub Pages does not support .htaccess)
The other thing is, you'll need to remove all the folders from the folder _posts, as explained here:
If you organized your categories as
/_posts/code/2008-12-24-closures.md, you will need to restructure your
directories to put the categories above the _posts directories, as
follows: /code/_posts/2008-12-24-closures.md.
You are probably working locally with a Jekyll version which diverges from GitHub Pages' (currently is Jekyll 3.0.3). That's why your site works locally and doesn't work there. To avoid that, build Jekyll with Bundler (a dependency manager). On this answer you can see how to do that, step-by-step.
Hope to have helped! :)
Note: If you get stuck in how to adapt your theme to work with GitHub Pages, you can try GitLab Pages, as you can easily set the Jekyll version you want to use to build your site. For example, this project builds the site with Jekyll 2.5.3.

Relative links in Github Pages without Jekyll

I created a single-page static website which has been uploaded to GitHub Pages. I have come across the common problem related to GitHub Pages and relative links.
i.e. "assets/img/img.png" becomes "assets/css/assets/img/img.png"
I found some solutions which involved Jekyll and creating a base url in the _config.yml file.
Is there another solution which does not involve Jekyll?
Use urls relative to root : /repoName/assets/img/img.png.
The easiest way to serve static files on GitHub Pages without Jekyll is to create a file .nojekyll in the root of the repository. That will tell GitHub not to parse files as Jekyll.