Im working on a site using jekyll. I want to change the url of all pages in a directory without having to write permalink: url in every front matter.
I have a directory jobs in pages
pages
jobs
example.markdown
otherexample.markdown
I want all pages in jobs to have the url /talent/filename.
I saw this and tried this:
defaults:
-
scope:
path: 'pages/jobs'
type: 'pages'
values:
permalink: 'talent/:slug'
The result in the _site directory was this:
Talent
:slug
index.html
with the other pages just vanishing entirely. I have tried a number of the variables listed here, with similar results. Does anyone know what is going on?
thank you.
You forgot a trailing slash '/' in the path.
the example below should give you the desired generated output.
if you have set permalink: pretty globally it would create a folder for each title with an index.html inside
if not just the files like yourtitle.html
defaults:
-
scope:
path: "pages/jobs"
type: "pages"
values:
permalink: /talent/:basename.html
Related
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
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.
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
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.
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/