Jekyll website with Staticrypt protected post, Where to put the encrypted.html? - html

I'm using Jekyll for my blog. I want to protect some blog post with a password and I've decided to use Staticrypt.
I can encrypt the index.htmlpage of one of my blog post with the Staticryp CLI and my custom password_template.html. It outputs a index_encrypted.html.
My question is: Where do I put the index_encrypted.html? I can't add it to the _site since Jekyll return the build to default everytime I serve it.
I tried adding the index_encrypted.html to the _includes folder and calling the page from the .md post like this:
{% include index_encrypted.html %} but this just break the page.
Thank you!

I figured out how to do it.
Here's what I did:
Put the index_encrypted.html in _includes and _layouts
Add a permalink: /index_encrypted.html in front matter of the .md post you're targetting.
Add a layout: index_encrypted in front matter of the .md post you're targetting.
Delete the whole markdown content of the .md post.
Voila!
You front matter should look like this:
---
title:
date:
tags:
description:
layout: index_encrypted
permalink: "/index_encrypted.html"
---
Edit: Make sure to create a copy of your .md post for later use.

Related

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.

generate subpages from template in jekyll

Is it possible to have a template in Jekyll, that will be filled for each subpage of a certain category with different data..
Say I have portfolio page, then I link to my works from there, each separate work page is using the same template, just the text and pics are changing.
So what I would like to have is portfolio/work1, portfolio/work2 generated from the same template and then I would iterate over _data yml files to fill in details for each work...
Is that possible in Jekyll? I couldn't find any articles on that topic.
You can use default setup for your portofolio folder.
1. In _config.yml, set :
defaults:
-
scope:
path: "portofolio"
type: "pages"
values:
layout: "work"
2. Create a _layouts/work.html template.
_
3. In your portofolio/indexhtml page
If you want to override layout, just do :
---
layout: page
...
---
This can be done with 'Collections' which is a function in Jekyll. See Jekyll Collections. If you are not sure what Collections is for then maybe Ben Balter's explanation could help.
In your situation: You want a portfolio page with subpages for each piece of work. Create a collection named Portfolio in your _config.yml like below:
# Collections
collections:
portfolio:
output: true
Then create a folder called _portfolio in your jekyll files. You then can clarify in your front matter on each piece of work i.e. work1.md inside _portfolio which could display images, tags etc along with content like you would write a post in Jekyll. In your front-matter for each work example, you can define what template/layout you would want to use for the work examples.

How to have Jekyll-Bootstrap not put "index.html" in the navigation

I'm a happy Jekyllbootstrap user, however the index.md template is compiled to index.html. This is expected, but for me undesired behaviour.
When the navigation links to the homepage it uses index.html on the anchor. I can get around this using an nginx redirect, but I don't want to have any links on my site that I'm "fixing" using 301 redirects. I'd like it to generate the correct link in the first place.
So to be clear. I don't want jekyll to ever link to index.html but instead link to /.
You can modify the variable HOME_PATH in _includes/JB/setup. By default it is {% assign HOME_PATH = "/" %}.
I found the answer to this. I had to set the following at the top of my index.md file:
---
layout: page
title: Home
group: navigation
permalink: /
---
The key part here being permalink: /

Jekyll : Using links to internal markdown files

md file with a link to Folder/file.md
When jekyll generates the index the link to the file is still folder/file.md and so doesn't connect to the generated file.html. Can jekyll replace links in markdown with their corresponding html files?
I really want to to maintain my folder structure (7 or so subfolders, each with 3 markdown files).
The answer since December 2016 is to use the jekyll-relative-links plugin.
It is a white-listed plugin if you are hosting on GitHub pages so you probably already have it.
If you are not using GitHub pages you will need the following installation instructions (from the README):
1.Add the following to your site's Gemfile:
gem 'jekyll-relative-links'
2.Add the following to your site's config file:
gems:
- jekyll-relative-links
The tag you're looking for is {% link %} and it arrived in 2016.
If you had {% link _funkyCollection/banjo.md %} it would generate the right path to the output file funkyCollection/banjo.html, or funkyCollection/banjo/index.html, or whatever, wherever it ends up being.
This is what I did to solve this problem with jekyll 3.8.5.
For link in root directory: /file.md
---
layout: page
title: Root File
permalink: /file/
---
This file is in root directory.
For link in subdirectory: /folder/file.md
---
layout: page
title: SubDir File
permalink: /folder/file/
---
This file is in sub-directory.
Now to link these file:
[Root File]({{site.baseurl}}/file/))
[Sub Dir File]({{site.baseurl}}/folder/file/)
Hope this helps someone.
i've written a simple plugin to solve this. put this in _plugins/, and make links refer to the *.md files (so github rendering linking works); if you build it with jekyll (when you are able to run plugins) the links are changed to *.html. since github doesn't run plugins, this isn't applied.
module ChangeLocalMdLinksToHtml
class Generator < Jekyll::Generator
def generate(site)
site.pages.each { |p| rewrite_links(site, p) }
end
def rewrite_links(site, page)
page.content = page.content.gsub(/(\[[^\]]*\]\([^:\)]*)\.md\)/, '\1.html)')
end
end
end
it's not perfect (i'm sure you could fool the regex) but it has been good enough for my purpose.
A Folder/file.md page will result in creation of a _site/Folder/file.html page.
So when your link to this page it's [Link to page]({{site.baseurl}}/Folder/file.html) not [Link to page]({{site.baseurl}}/Folder/file.md).
Jekyll will never rewrite file.md to file.html in url. So you have to set your links targets yourself to the resulting page.url which is usually a html file but can be css, je, json, ...
If you use permalink: /folder/folder/ in any file.md, it will generate a /folder/folder/index.html file which can be reached with [Link to page]({{site.baseurl}}/folder/folder/)
I've run into this and written a basic Jekyll/Kramdown plugin. It's less likely to break than the regular expression approach.
As long as your link doesn't start with http:// or something like it, and ends with .md, it will convert links to their lowercased and hyphenated names.
Of course, you could always modify the behavior to fit your needs.

How can I change the blog post URL of a Jekyll website?

I'm using Jekyll to create a blog/website. I have it setup so that it displays the URLs like this:
http://example.com/blog/title-of-post
I want to modify it to change the the "blog" part of the URL. For example:
http://example.com/writing/title-of-post
How can I do this?
You can do this by setting the permalink in your _config.yml file. For example:
permalink: /writing/:title
Note that this assumes that jekyll is building your entire site and isn't just powering the "blog" directory. If jekyll is only writing to your "blog" directory, then all you would need to do is rename that to "writing".