Creating a blog using Jekyll and was hoping to link posts together using the following syntax:
either
[xyx]({% post_url 2020-07-17-xyx%})
or
[xyx]({% link _posts/2020-07-17-xyx.markdown %})
In both cases the link that is created is:
http://000.0.0.0:4000/jekyll/update/2020/07/16/xyx.html
instead of
http://000.0.0.0:4000/myblog/jekyll/update/2020/07/16/xyx.html
notice myblog is missing
It has to with the version of Jekyll. If one uses Jekyll 3 this does not work - I assume you have to prepend the base url (even if I am not sure how to do that). Using Jekyll 4 this works.
Update for Jekyll 3 you prepend baseurl as follows
{{site.baseurl}}
therefore the complete syntax is
[xyx]({{site.baseurl}}{% link _posts/2020-07-17-xyx.markdown %})
Related
I use Hugo to deploy static web, using Markdown and the problem I would like to sort out is simple.
I would like to find the simplest and compatible with Markdown language way to make my web links open in different tab.
The method I use now is below:
< rawhtml >}}Rasmus Lerdorf</br>{{< /rawhtml >
[link with title](http://nodeca.github.io/pica/demo/ "target="blank")
First method working but it is HTML second method not working.
Thank You.
You need to create a new file at /layouts/_default/_markup/ called render-link.html.
In that file, you can then customise it to something like:
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank" rel="noopener"{{ end }}>{{ .Text | safeHTML }}</a>
Here is what would happen:
[link1](../something/ title="title") => link1
[link2](https://example.com) => link2
It will only add it to URLs with "http" and "https".
The documentation for render-hooks is available here: https://gohugo.io/templates/render-hooks/.
Or you could just put the link in as you have it using regular, old HTML.
IMHO, beating yourself up over the failings of Hugo and whatever theme is in use is counter-productive. Markdown was supposed to be a quick and dirty way for users who couldn't grasp the basic fundamentals of html to create and display content on a wiki.
Think about the current situation. Does using Hugo, a theme, and Markdown really save any effort when they simply can't produce the output you need because the features you need don't exist in that combination natively?
When you need to spend hours/days researching and learning how to manipulate the generator's template to generate the output you need from Markdown and Hugo, tell me, where exactly are those time savings?
This is why people using tools such as Flare, RoboHTML, and Paligo laugh at users who brag about how fast they Hugo site generates html pages.
I use Jekyll to create documentation for software products. I have 30 +
different products that have a common LIQUID template but different content. Every single product documentation has its own table of content.
For one project, everything is OK. I have a content folder as well as css/js folders. I run "jekyll serve" and publish a project.
The problem is that, I do not want to have 30 Jekyll projects stored one next to another with similar css, configs, js folders and will only differ in content part.
The question is: how can I organize the internal structure so I have a
single project with a common layout and 'x' different content folders inside the single project?
Like:
_product1/
some_subdir
'topic.md'
_product2/
some_subdir
'topic.md'
If it's possible, how can I then manage the output? I need to publish product 1 and product 2 ... product 'x' separately.
Thank you for the assistance.
UPD: Here is the demo project on GitHub: https://github.com/plywoods/JekyllDocumentationDemo
The way to have this content separation in Jekyll is through the use of Collections.
Here is an example of a Jekyll website using Collections:
https://github.com/netponto/netponto.github.io
_meetings, _members, and _sessions are different collections and analogous to your _product1, _product2, etc.
You can customize the output / how the URL is going to be in the _config.yml of your Jekyll site. For example:
collections:
meetings:
output: true
permalink: /reunioes/:path/
sessions:
output: true
permalink: /sessoes/:path/
To display the items of a collection, for example the "sessions" collection, you do something like this:
{% for session in site.sessions %}
<p>{{ session.title }}</p>
{% endfor %}
If you're having issues implementing the Collections, put together a reproducible example on GitHub, so that others can see what you've tried to do and point what's missing.
By default, Jekyll uses *.html, however, the program I use (Sublime Text 3) has an a package that adds Liquid syntax support but it will only auto detect and do the code suggestions if the file has the extension *.liquid. The other problem is, Jekyll is looking for default.html as well as the other layouts. How do I make Jekyll look for *.liquid files instead like default.liquid?
In the bottom right hand corner of sublime it will have the name of the filetype being used, for example 'HTML'. If you click this you can change it to liquid.
What worked for me is to rename files to *.liquid.html and then
update the front-matter to use the new name, e.g.,
Including abc.liquid.html in default.liquid.html
=== default.liquid.html ===
---
---
{% include file.liquid.html %}
Using layout default.liquid.html in a Blog Post
---
layout: default.liquid
title: "My post title"
date: 2021-01-24 19:00
---
A very basic question.
I can not find out how to refer or cite a post in a page.
If this is my post
---
layout: post
title: "Serve Jekyll Websites with servr and knitr"
categories: [jekyll, rstats]
tags: [knitr, servr, httpuv, websocket]
---
The R package [**servr**](https://github.com/yihui/servr) can be used to set up an HTTP server to serve files under a directory.
How I am suppose to cite it in my page
---
layout: page
title: About
permalink: /about/
---
You can find out more info in this post
Could you help me out ?
You can do this 2 ways:
Copy-pasting the link generated for your post as a link to it.
[Check Out My Post!](www.example.com/posts/2015-10-1-name-of-post/)
This definitely works, but will break/fail when you decide to change link style, or have another permalink, or when you change file names.
The smarter way: Jekyll's built in post_url
Jekyll has a built in function that allows you to internally link or cite back to posts on your website. Here is the documentation for it, but I will explain the syntax and usage as well.
Assuming you want to link to a Jekyll post with the filename of 2015-07-17-jekyll-servr-tutorial.md which is located in the _posts folder, the syntax for this would be:
{% post_url 2015-07-17-jekyll-servr-tutorial %}
{% post_url /tutorials/2015-07-17-jekyll-servr-tutorial %} if you have your posts organized in a subdirectory called tutorials
The R Package [servr]({% post_url 2015-07-17-jekyll-servr-tutorial %}) if you want to make hyperlinks.
There is no need to include the file extension name when using this liquid tag function.
Here is additional information and a tutorial on how to use Jekyll post-links that you might find useful as well.
I would like to use Jekyll to create a site. not a blog. Is there a way to avoid to have the creation date specified in the url and in the page's file name?
I think that the idea behind Jekyll is brilliant, but it seems too tied to blog generation content while it could be useful also in a more general use case.
In the _config file you can change the permalink to anything you like, for example mine is
permalink: /blog/:title
As for the date you can choose your own date using the YAML front matter, again in mine i have
title: example
date: you can pick what ever date you want
What the docs say:
You configure permalinks in your _config.yml file like this:
permalink: /:categories/:year/:month/:day/:title.html
If you don’t specify any permalink setting, Jekyll uses the above pattern as the default. The permalink can also be set using a built-in permalink style:
permalink: date
Although you can specify a custom permalink pattern using template variables, Jekyll also provides the following built-in styles for convenience.
date = /:categories/:year/:month/:day/:title.html
pretty = /:categories/:year/:month/:day/:title/
ordinal = /:categories/:year/:y_day/:title.html
none = /:categories/:title.html
Source: https://jekyllrb.com/docs/permalinks/
This is the basic setting I use:
permalink: pretty
This sets pages to the pretty permalink style. Thus '/contact.md' will become '/contact/'.
How I use it for blog posts:
permalink: /blog/:title/
This makes sure the path contains the (sluggified) title.
How I use it for collections:
permalink: /desiredpath/:name/
This makes sure the path contains the filename.
If you aren't producing blog pages, you can create files in the directory structure mapping to certain URLs. Running on localhost, if your directory has the structure
- _layouts/
- config.yml
- index.html
- some_other_page.html
- some_directory/
- index.html
- some_sub_page.html
You'll have content at the following locations after jekyll has processed the files:
0.0.0.0:4000 (index.html)
0.0.0.0:4000/some_other_page.html (some_other_page.html)
0.0.0.0:4000/some_directory (some_directory/index.html)
0.0.0.0:4000/some_directory/some_sub_page.html (some_directory/some_sub_page.html)
You can also use the permalink attribute on each post to set one manually, or set a different default in config.yml Permalinks only have a small subset of variables available to use and need to be defined in every single file you want to put in a non-standard location.
This directory structure will automatically categorize your posts too. So you can have:
- some_category (defined in the yaml front matter or the _config.yml
- index.html
- _posts/
- some_post.md
- some_other_post.md
And posts will automatically have the category 'some category', and index.html will appear at 0.0.0.0:4000/some-category, with the default permalink format. The category variable is available as :category in the permalink format string.
I came across this old question while looking for a way to organize jekyll pages in a _pages directory, similarly to _posts. then access this pages without displaying the whole path in the url.
The approach that worked better for me, is to use jekyll collections as follows:
1 - Add a pages collection in _config.yml :
collections:
pages:
output: true
permalink: /:path/
2 - create a new directory named _pages (it should have the same collection name, prefixed by _)
3 - add the pages in the _pages folder, as .md or .html files starting with YAML Front Matter.
eg. /_pages/about.md will looks like:
---
layout: page
---
<!-- about page content -->
after building that, the URL of the about page will be <your-web-site>/about .
Alternatively, to display a collection name, you have to define its permalink as:
permalink: /:collection/:path/