Generate all posts in a single subdirectory - jekyll

I have a jekyll blog with some static files, my blog index is generating at /blog while all the posts are getting generated at /. How can I make it so that the posts get generated inside the /blog subdirectory?
Note that I am not looking to move the whole Jekyll installation to a subdirectory as I still want my sitemap, static pages etc to be at root.
I am not sure what code to provide but I am using this theme with gulp 4 and other upgraded packages.

Change permalink in _config.yml from
permalink: /:title/
to
permalink: /blog/:title/
You can read more about permalinks in Jekyll documentation.

Related

Build pages with slug.html rather than slug/index.html in Jekyll (ugly URLs)

I have a page with the slug about-us. By default, Jekyll builds this:
/about-us
/index.html
However, I want this instead:
/about-us.html
Reading through the Permalinks documentation, it looked like I could use this in the config
permalink: /:slug:output_ext
However, this produces the same output as above.
How I configure Jekyll to write the pages as their own .html page, rather than in a folder with an index.html?
Jekyll only generates /about-us/index.html if you've permalink: /about-us/ in the page's front matter or if you've permalink: pretty in your config file.
Ensuring neither of the above conditions should generate /about-us.html

Link in jekyll menu lead to "404 page not found" erros

I'm new to using jekyll and I think I'm missing something but I can't figure out what.
I built a jekyll page which I compile using
bundle exec jekyll build
then I uploaded the contents of the _site folder to the public_html/ folder of my webhoster (name.com).
All menu links, lead to 404 error pages: The menu links generated in the html files point to things like "https://myurl.com/people" while the actual file is called "people.html" so that is why I'm getting a 404. The way I see it, I either need jekyll to generate menu links that include the ".html" file extension, or somehow get my webhoster to serve "people.html" when "people" is requested.
Chris
To alter the link structure for all of your files, use permalink (with proper formatting) in your config file. For example:
# _config.yml
# same as `permalink: none`
# note that its ':output_ext' instead of '.html'
permalink: /:categories/:title:output_ext
Source: Official Docs

Jekyll extension-less permalinks with markdown

From the Jekyll docs it says (using .md format):
Clean URLs can also be achieved using the permalink front matter variable. In the example above, using the first method, you can get URL http://example.com/other for the file other.md by setting this at the top of the file: permalink: /other
Here is an example my page front matter:
---
layout: page
title: Contact
permalink: /contact
---
Everything works fine when I'm using jekyll serve but when I build and upload to my static host it doesn't work. The file structure Jekyll outputs doesn't make sense for the functionality it claims from the docs.
.
|-- css/
|-- index.html # => http://example.com/
└── contact.md # => http://example.com/contact.html
I want to be able to go to http://example.com/contact and have it show contact.md. I know I could have similar functionality by manually putting my files in folders (and then renaming them all to index.html) like it says in the docs here, but I don't want to have to go through the extra step and I don't prefer the trailing / e.g. http://example.com/other/.
I am using Jekyll 3.0.1
I have found these questions but they don't address the problem I'm facing.
How to link to a page with page.url without the html extension in Jekyll?
How to make all posts have a permalink with custom format "domain.com/blog/title"?
Can Jekyll omit index.html from folder URLs?
I am also using clean permalink in my jekyll blog.
Here is my frontmatter:
---
layout: directory
title: About
permalink: about/
---
Got any different? , it is trailing slash at the end of URL. I know, you don't want to see any trailing slash at the end of URL, but for that you need to use nginx, because Jekyll generate all post/page like this /folder/index.html.
I think you are doing it correctly, it is just a matter of configuring your webserver properly (assuming it supports removing the extension). It works properly locally cause the built in jekyll webserver can do it by default. The docs have info on this here:
http://jekyllrb.com/docs/permalinks/#extensionless-permalinks
On AWS S3 it says you can host with extensionless urls by uploading files with no extension at all, and then setting the content type to text/html. I don't think it is possible to get jekyll to output contact.html as just contact with no extension. So you get the web server to remove the extension, if it supports that (on s3 I use the trailing /).
This has some interesting info too:
https://github.com/jekyll/jekyll/issues/3345

Configure generating path with Jekyll

If there are files called members/alice.md and members/bob.md, the Jekyll generated position will be members/alice.html and members/bob.html. How can I set them to be members/alice/index.html and members/bob/index.html?
You can do this with Permalinks.
Here are 2 approaches that may suit you:
1. Per-page YAML frontmatter
If you just want specific pages to have that behavior, just add a permalink: option in your YAML frontmatter for your Markdown post.
For example: In members/alice.md's YAML frontmatter add:
---
permalink: members/alice/
---
2. Edit the _config.yml file
As per the documentation I've linked above, the simplest way (which I recommend) way to achieve this is with Jekyll's built-in pretty option.
Add this in your _config.yml:
permalink: pretty
This removes the .html from the static output by making all posts have their own folder and named as index.html.
Your browser would then display this as yoursite.com/members/alice/, note that the index.html is hidden, a behavior on most browsers. If you head on over to peek at the output _site folder, you'll see a folder in members named alice, and a file index.html inside.
Also note that:
You need to restart the Jekyll server every time you make a change in _config.yml, unlike other files that the Jekyll server will detect changes and regenerate, this configuration file will not and the WEBrick server must be restarted for changes to take effect. :)
You could also refer to the documentation on other more customizable options as well. Here's also a tutorial for reference too.

Post permalinks not being parsed in Jekyll on GitHub Pages

I've created a new site at GitHub Pages, using Jekyll. I'm using a custom permalink format in the following form:
permalink: /:title
This is because I've moved my blog over from WordPress and want previously existing links to continue working. When I run the server locally with "jekyll serve", it works fine - however, once it's hosted on GitHub Pages, the links don't get parsed correctly, leading to tags like this one:
<a class="post-link" href="/:title">Markdown and HTML</a>
Further information - I am using a custom domain, with my _config.yml containing:
url: http://domain.com
And my CNAME containing:
domain.com
Could anyone shed some light on why this occurs? Thanks.
You're trying to use a functionality that was implemented in Jekyll 2.5.
As Github pages runs Jekyll 2.4, it breaks :-(
The only way to do what you want is to set default permalink in you _config.yml file.
permalink: :title/