I am developing my blog in Jekyll (3.0.0 beta), currently on localhost,
When i am trying to implement the pretty permalink and i try to visit a post it shows a WEBrick error.
If i apply the /:year/:month/:day/:title.html it works fine do you have a clue why isn't it working with pretty permalinks?
This is the error I get:
/2015/08/03/are-permas-working.html' not found. WEBrick/1.3.1 (Ruby/2.1.6/2015-04-13) at localhost:4000
Once you set Jekyll permalinks to pretty in _config.yml like so:
permalink : pretty
... and restart your WEBrick server (a restart of the server instance using jekyll serve or bundle exec jekyll serve [if following GitHub] is needed for the new values to take effect, your permalinks will no longer be in the format of YYYY/MM/DD/title-slug.html since they are now "pretty". The new format for your links will be /:categories/:year/:month/:day/:title/. This is in accordance to the format determined by the pretty variable as defined here in the documentation.
What this means for you is that your original link for the 'Are permas working' post is no longer at localhost:4000/2015/08/03/are-permas-working.html, rather they are now at localhost:4000/2015/08/03/are-permas-working/ since you don't have a category defined.
You're experiencing this error because after you've made the change and restarted your server you most likely did not navigate to the post from your homepage (which will have that new link to point to the post), rather you just refreshed the page on your browser, which will throw a 404 since the page is no longer there.
Bonus, Jekyll makes posts pretty by creating folders 2015 -> 08 -> 03, and then a folder for that specific post, with an index.html inside it.
Also, if you wanted "pretty-fied" links that don't have the dates there, you'll need to manually specify that using this:
permalink: "/:categories/:title"
This ensure will hide the .html extension and also get rid of date values.
EDIT: From the comments I stated that using /:title for permalinks might not work since there are conflicts with non-post pages, I stand corrected. If you wanted short permalinks like user.github.io/title-of-blog-post/ you would just need to set permalink : /:title and you're good to go. However, if you have non-post pages such as an about page, a credits page, you should explicitly set permalinks on those pages to be /about and /credits on the YAML frontmatter to avoid the edge case of also having a blog post with the title about and accidentally overwriting the non-post page.
Related
I have a simple use case on a site that I am publishing with Jekyll:
I need to list values of a certain type. Let's say one type has URIs of the form .../base/typex/value. I am generating a file .../typex/value.md and Jekyll happily serves it.
I also want to serve pages listing all values. That page should be named .../base/typex or .../base/typex/ (I don't mind either way).
I cannot use the file .../base/typex/index.md to do this because in some cases, index is actually a valid value.
I am creating .../base/typex.md, but Jekyll ignores it, regardless of the permalink that I put in there that specifically has no trailing slash. Instead of serving the file, Jekyll serves the directory listing.
Is there any way I can solve this puzzle? If Jekyll had support for serving .../base/typex.md, everything would be good, but it seems as if as soon as there is a directory .../base/typex/, Jekyll simply ignores this file. Is there any workaround or configuration I can use? (And this is going to get hosted on GitHub, so I have no control over the Web server configuration.)
( https://github.com/dret/webconcepts/issues/25 has the backstory, in case anybody is interested. But the issue is fully described here, so there is no need to follow that link. )
I just tried to reproduce it with your provided repository, thanks for that!
If you create a file http-method.md in /concepts and set the permalink to
permalink: /concepts/http-method/, my local jekyll serves the page both in /concepts/http-method and /concepts/http-method/
I am looking for ways to make some of the posts on my blog visible only to myself but can't seem to this in Hugo.
Is there any way around this such as setting a password for certain posts?
Or is the feature supported but I just haven't found it?
Since Hugo just generates the static HTML, the question can be widened to: how to password-protect any static content on the web server.
That's doable.
It depends what is your web server using: Apache or Nginx or something else.
In Apache case, set up password authentication via .htaccess. See tutorials like this.
In Nginx case, set up password on your server block section, see tutorials like this.
For other server (IIS?), google accordingly.
Some people will want to downgrade this question, but in my opinion it's very valid, for example, if you want to post portfolios, CV's and whatnot on your personal website and limit public access
Make a landing page on Hugo site, password-protect the URL and give visitors the password. Easy, fast and still static!
My way to keep posts private is to set the draft flag in the front matter:
TOML
draft: "true"
A good practise for me is to connect a local instance of Hugo with GitLab/GitHub. If you want to see your website or a specific post as a rendered version you can turn on and off the visibility of pages using the draft flag with true and false.
If you have finished your tests you can push the final version with or without the draft flag active to the repo and sync it with your server side installation of Hugo.
Posts are displayed in multiple places (RSS feeds, search results, sitemap etc.).
Here is an article with an updated checklist and a solution to publish hidden posts with Hugo
Installation
git clone --recurse-submodules git#github.com:RoneoOrg/hugo-offtherecord-demo.git
cd hugo-offtherecord-demo
hugo serve
Usage
Set offTheRecord to true in the Front Matter of the posts you want to hide. That’s all!
See the source for details
Cross-posted in a Github issue at https://github.com/SeanKilleen/seankilleen.github.io/issues/189
Digging into an issue with GitHub pages that appears like it might be recent.
I noticed an up-tick in 404s via Google Analytics. It appears that posts with trailing slashes are becoming 404'd, but appeared just fine without the slash.
My local Jekyll instance generates the following structure for how-to-leave-a-company-well.md from Feb 2015:
/2015
/02
/how-to-leave-a-company-well.html
/how-to-leave-a-company-well
/index.html
So, the following URLs work just fine locally:
http://localhost:4000/2015/02/how-to-leave-a-company-well
http://localhost:4000/2015/02/how-to-leave-a-company-well.html
http://localhost:4000/2015/02/how-to-leave-a-company-well/index.html
http://localhost:4000/2015/02/how-to-leave-a-company-well/
Those last two URLs that I've bolded do not seem to exist on my published site after GitHub Pages generates the documents.
I cannot reach http://seankilleen.com/2015/02/how-to-leave-a-company-well/ or http://seankilleen.com/2015/02/how-to-leave-a-company-well/index.html
This seems to indicate to me that GitHub Pages is doing something differently than my Jekyll installation. Given that the 404 spike is recent, I'm wondering if there might have been a change related to this.
Does anyone have a thought on how I might be able to diagnose this? It's a bit of a black box for me when my local is doing what I expect and I can't see the Github Pages process.
Jekyll 3 changed the way the permalinks worked, and dropped the trailing slash if your permalink setup did not contain one - yours does not contain a trailing slash at the end of your permalink in the config file. Jekyll 3 now respects that and thus your page is a 404 when there is a trailing slash in the url (since you want it without it).
https://jekyllrb.com/docs/upgrading/2-to-3/#permalinks-no-longer-automatically-add-a-trailing-slash
You may want to check which version of jekyll you have installed - you may be on 2.x and GH is now 3.x
When working locally, are you telling jekyll to use the GH pages gem? if you
don't do this you may get different behavior on GH than local. I do not do this, so I can't tell you how to do it (or if this particular issue would happen), but I do know that you should do it if you want to preview locally what you will get when serving via GH.
I'm contributing to an open source project that has its documentation built in Jekyll and hosted on Github Pages. I'm trying to add a redirect in the documentation, so I've forked it and am using jekyll-redirect-from in the fork. However, the redirect simply doesn't seem to be applied. That is, the jekyll build folder doesn't contain any static file to hold the <meta redirect> html that jekyll-redirect-from is supposed to generate. Instead, when I visite the URI that's supposed to be redirected, I just get a 404.
I've followed all the steps in the jekyll-redirect-from docs, including:
Adding jekyll-redirect-from to the Gemfile (code)
Adding it to my _config.yml file (code)
Adding the redirect_from key to my page's front matter (code)
I'm using jekyll 2.5.0 and jekyll-redirect-from 0.8.0 (the full gemfile is linked above). I'm building the project with bundler (using bundle exec jekyll serve), which is how the project's always been built.
Jekyll isn't showing any errors—the static file that should hold the redirect simply doesn't show up.
I can't for the life of me figure out the problem. Maybe I'm overlooking something obvious, or maybe there's some sort of subtle incompatibility in my dependencies?
D'oh. The issue was that the safe option needed to be set to false for the plugin to run. This tripped me up because I know Github Pages sets safe to false as well, and yet jekyll-redirect-from generally runs there. But that appears to be because GH Pages has made an explicit exception to allow it.
My issue was that I had:
redirect_from: /a/path/
redirect_from: /other/path
And repeated directives don't work like that in YAML.
Instead, it should be:
redirect_from:
- /a/path/
- /other/path
Is it possible to have different permalink settings for different directories?
For example, if I have a Jekyll setup where blog entries are written into /blog/_posts/ and news items in /news/_posts, then by default each entry will have permalinks in the format /blog/2011/06/24/slug.html and /news/2011/06/24/slug.html.
The permalinks for blog entries are fine as they are, but I need to change the permalinks format for news to something different, say /news/2011/slug.
I've tried changing the permalink settings in the YAML front matter for the layout used by news item, however, this does not work since permalink settings in YAML front matter are not interpolated (as confirmed in the answer to this question).
Is there a mechanism to configure path specific settings in _config.yaml? Or is there a better what to achieve this results?
Not sure if this will be any help now but I ran into the same problem trying to make a blog/portfolio and wanting to have /articles/2013/.. and /work/2013/..
What I did is just change the permalink to:
permalink: /:categories/:year/:title
and added 'articles' as a category for my blog posts and 'work' as a category for my work and it worked fine.
Just got inspired by jose's comment. Why not do this:
permalink: /:categories/:title
and then in the front matter for your blog just do
categories: blog 2013 05 01
for news only do
categories: news 2013
The only way you can achieve that is by having two different jekyll instances.
You could have (for example) a full site with the pages and blogs, and a "microsite" inside the news folder, with it's own ´_config.yaml´ . The "top" would have to ignore the news directory completely, and the news directory would have to be configured to generate its output inside "../_site/news".
The biggest hurdle would be that you would not be able to run Jekyll as a server; you would have to use a script (i.e. a Rakefile) to generate the static pages for both jekylls, and serve them with a different server (i.e. unicorn).
Like I said, it'd be a bit of a hurdle, but doable in 1h or less.