How to change the URL of the title in Jekyll? - jekyll

Is it possible to change the target URL when clicking on the value title defined in _config.yml ?
To define the context, I have my static HTML website hosted on GitHub, it's a one page website. I have on the same repository the Jekyll blog accessible on mysite.github.com/blog.
When I click on the header title, the Jekyll blog redirect me to / which is my website and I would like to be redirected in /blog.
What is the simpliest method ?

You need to rewrite the header.html of the minima theme template. The goal is to change the target of the link in the header.
To do that :
Create a folder _includes and a file header.html inside
Copy and paste the original code for the official repository
https://raw.githubusercontent.com/jekyll/minima/master/_includes/header.html into the header.html file
replace the content of href="{{ "/" | relative_url }}" by href="{{ "/blog" | relative_url }}"

Have you tried setting url and baseurl in the config for the blog? Baseurl should be used for the "home" page.

Related

Generate pages from _posts in subfolder in Jekyll

I have a project where I have posts on main page of the blog and I would love to have another posts folder inside subfolder(s).
I am talking about this structure:
_posts
_posts/2020-04-04-Testmain.md
subpage/_posts
subpage/_posts/2020-04-04-Testsub.md
subpage/index.html
index.html
I can access posts from subpage by using {% for post in site.categories.subpage %} inside subpage/index.html but I can't find a way how to force jekyll to also generate posts in the subpage folder so I can access it at page http://127.0.0.1:4000/subpage/testsub
Is it even possible? Or is it better to follow this structure?
_posts
_posts/2020-04-04-Testmain.md
_posts/subpage
_posts/subpage/2020-04-04-Testsub.md
If so, is there some setting required to make the post at http://127.0.0.1:4000/subpage/testsub ?
Found the solution!
In _config.yml you can use permalink: /:categories/:title
And with following file hierarchy:
_posts
_posts/2020-04-04-Testmain.md
subpage/_posts
subpage/_posts/2020-04-04-Testsub.md
subpage/index.html
index.html
You will get these websites:
http://127.0.0.1:4000/
http://127.0.0.1:4000/subpage/
http://127.0.0.1:4000/subpage/testsub
And you can still access all posts from selected subfolder with {% for post in site.categories.subpage %}

Jekyll not showing the same pages in _site folder as compared to running it locally

I am new to making website using jekyll. When I run the website on local server using jekyll serve, it runs perfectly. I used jekyll build to build files for FTP server. Problem is the pages built in _site folder are without themes and images shown while running it locally.What can be its solution?
You have to customize and override your CSS styles, images or pages in Jekyll. That's why theme changes are not applied and "Jekyll Serve" command resets your changes.
Look at this Official Github Help page: Customizing CSS and HTML in your Jekyll theme
And Tom Kadwill's Page How to Override CSS Styles in Jekyll
Locally, your site is served at http://127.0.0.1:4000/ which the root.
Your _config.yml baseurl: "" is empty.
Once you publish you site from something else than the root, say, https://example.com/blog/, you need to check two things :
that your baseurl: "/blog" is set accordingly to path.
that you call your resources using {{ site.baseurl }}{{ post.url }} or with filter {{ image.url | relative_url }}

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/

How do I get the host url in post file?

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

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: /