Post images are basically pulled from the assets folder.
However, the image in my post is structured as follows.
_posts
Docker
assets
images
2021-05-21-Dockerfile
FROM-command.png
RUN-command.png
2021-05-21-Dockerfile.md
./assets/images/2021-05-21-Dockerfile/FROM-command.png
With Jekyll's default settings, the image path of the post is specified as in the form above,
how do I change it to the form below?
./Docker/assets/images/2021-05-21-Dockerfile/FROM-command.png
Where Docker is the category name of the post.
I registered defaults in the following way, but it doesn't work.
#_config.yml
defaults:
-
scope:
path: "_posts/:categories/assets/images/:title/"
values:
permalink: /:categories/assets/images/:title/
You can use the filter relative_url, see docs.
You can also use abslout paths
![My Image](https://...)
Related
I would like all posts and pages on my Jekyll site to have the same link structure: example.com/my-title, regardless of the directory structure I use to store my files.
Looking at the documentation it seems like I should be able to implement this by putting the following line in my _config.yml:
permalink: /:title.
This almost works. All posts (in the _posts/ directory) get the correct URL. And all pages in my site's home directory also get the correct url. However, pages that are in subdirectories still have the directory path prefixed to the url. For example, if I have a page pages/cats/my-cat.md the URL is example.com/pages/cats/my-cat, instead of what I want (example.com/my-cat). If I set the permalink for that page directly in the front matter as /my-cat I get the desired outcome, but I'd rather not do this on every page.
Is it possible to remove the path from all page URLs?
I see a number of other questions about Jekyll permalinks but nothing that addresses this exactly. This answer from 2013 says that pages will "always remain relative path" but that's fairly old, and also seemed like a throwaway assertion rather than an evidence-backed claim.
You can use Jekyll defaults to apply fallback front matter for files based on a type and/or path. It has the same effect as setting the front matter inside each file. Here's how you could apply that permalink to all pages:
_config.yml:
defaults:
- scope:
path: ''
type: pages
values:
permalink: /:title
It's also a great way to set other common fields, e.g. layout.
Official documentation for further details: https://jekyllrb.com/docs/configuration/front-matter-defaults/
I bought a simple Jekyll template for a support site and have that up and running no issues.
I am trying to render my existing docs collection with separate layout. For background I am taking these docs and making a stripped down html file that has just the body content to use in a small modal pop-up window.
In my config file I have this:
defaults:
# _docs
-
scope:
path: ""
type: docs
values:
layout: doc
which renders my regular HTML files fine along with all my other template content in the target directory.
I am looking to also process this:
defaults:
# _docs
-
scope:
path: ""
type: docs
values:
layout: modal
The issue is that it seems in Jekyll can't do this out of the box. If add this to my config file it only uses the last one. If I try multiple config files they over write each other. I just want my full HTML docs using the doc layout in /docs and the HTML partial files rendered with the same docs collection using the modal layout in /modals as detailed in my previous post Multiple layouts for a single Jekyll collection?.
What I would like to do now is make a separate config file that builds ONLY the docs (using the modals layout) and NOT any of the other files (index, search, posts, 404 etc.) - just the docs collection with the alternate layout. I want the target folder to be the /modals sub directory of my main Jekyll.
This my hack so far - I won't even accept my own answer as it's not really a solution:
I have a second identical config file with this:
keep_files: ["docs"]
collections:
docs:
output: true
permalink: /modals/:name
I run this after the running the main config file. Keeps the normal docs build then adds the custom modal version.
The question is in jekyll.I put my images resource into assets/images/ folder.And I want to refer this image in my post file.
The site give these solution:
... which is shown in the screenshot below:
![My helpful screenshot]({{ site.url }}/assets/screenshot.jpg)
But how do I know the the host instead of site.url? So it will work fine in local and github page.
It's seems that the site is wrong. Calling an image can be done like this :
![My helpful screenshot]({{ site.baseurl }}/assets/screenshot.jpg)
Don't forget to set your baseurl depending on your hosting.
eg : if your site is at username.github.io/myblog, set baseurl: /myblog
Jekyll is static site generator, destination result of this generator is located on _site folder, on this folder we can find result of assets, css, javascript and html which generated from _post folder. Site is one of the variable to collect Sitewide information and configuration settings from _config.yml. Url can set on _config.yml
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.
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".