Jekyll does not create html page from markdown file - html

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.

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.

Adding Jekyll (only the blog portion) to my website

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.

Need to link to index.html

I try to create a bunch of local HTML files that should serve as a documentation for some software. No webserver should be involved, just HTML files viewed by a webbrowser. I use hugo to create the pages, but I have problems linking to the main page (index.html).
My config.toml is this:
#baseURL = "http://example.com"
languageCode = "en-us"
title = "foo"
theme = "mytheme"
relativeURLs = true
canonifyURLs = false
uglyURLs = true
and my main page is _index.md in the root folder.
How do I create a shortcode or whatever that creates a relative link to the index.html in the root folder (content folder in hugo). The index.html page gets created, but I have not succeeded to create a link to that page. Of course I could hard code the link, but this is not what I want.
The sample repository is at https://github.com/pgundlach/hugoexample/ .
I have tried a shortcode with a definition like {{ with .Site.GetPage "section" "_index.md" }}{{ .Relpermalink }}{{ end}} but this didn't work.
Disclosure: This is actually a question I have tried on https://discourse.gohugo.io/ but without any luck. So the question might be "stupid" or I am missing something obvious.
I am also a beginner. However, I think that the index.md file should be in your content directory. Then you should create an index.html file in your layouts directory for rendering the .md file.
Or am I missing what you are trying to do here?
Docs about the directory structure: https://gohugo.io/getting-started/directory-structure/

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.

Jekyll: All HTML files in /folder, now forced rendering through /folder/page/. How to change?

So I've tried looking here:
http://jekyllrb.com/docs/permalinks/
and here:
Show pages under one folder in Jekyll?
But this doesn't seem to resolve my issues.
So here is the situation:
Initially, I had all my Jekyll *.html files living in the /root folder of where I am running Jekyll, this was a bit messy, as there was over 30 *.html files, but when I did this:
jekyll build
jekyll serve
I would get the site propagating to: http://0.0.0.0:4000/
I now moved all the *.html files to a folder called /html (within the project root). When running:
jekyll build
jekyll serve
My site no longer renders at: http://0.0.0.0:4000/
But it renders at: http://0.0.0.0:4000/html/
I would like to remove the /html part of the URL, but as the above 2 links show, there was no previous question related to this.
Can anybody suggest how I can remove the /html part from my URLs?
Okay, so initially your folder structure looked like this, correct?
/_layouts/default.html
/css/whatever.css
/index.html
Now to your question:
Do you want to move the HTML files and nothing else to the html subfolder?
In other words, do you want to do this?
/_layouts/default.html
/css/whatever.css
/html/index.html
If yes, read David Jaqcuel's answer.
If not, continue reading my answer :-)
Or is it just that you don't want all your source files cluttering up your root folder?
If yes, you could move everything into the html subfolder, like this:
/html/_layouts/default.html
/html/css/whatever.css
/html/index.html
Then you need to tell Jekyll that the html folder is the root folder for the site's source files.
To do so, you need to add the following line to the config file (or create the file if it doesn't exist yet):
source: html
Important: the config file needs to be in the root folder of your project, even if you move your source files into a subfolder!!
Then all your source files are in the html subfolder, but the generated site will look like this:
/_layouts/default.html
/css/whatever.css
/index.html
In other words, the URL will still be http://0.0.0.0:4000/.
If you want to see an example, you can look at the source code of my blog:
I'm doing exactly the same there, only that the folder with the source files is called src.
By default, for pages in /html, Jekyll will generate a page like /html/page.html and so on.
I think you cannot add a permalink front matter default for a folder, you'll be obliged to set a permalink for each page you put in /html.
eg : for html/page.hmtl, you'll have to set :
---
permalink: page.html
---
This is the way without plugin. Otherwise, you can do it with a Generator plugin that will take all your pages in /html and change the all the target permalink.