Jekyll: Redirect from URLs containing colons - jekyll

I am currently converting a MediaWiki site to Jekyll (GitHub Pages). Unfortunately, MediaWiki category pages have URLs containing a colon ":" :
http://www.example.com/Category:Name_Of_Category
I would like to redirect these old URLs to new Jekyll pages with URLs in the form of:
http://www.example.com/name_of_category/
Therefore, I used redirect_from in the front matter of name_of_category.md, but Jekyll fails to build as the generated static html file containing the redirect has a colon in the file name:
Error: Protocol error # rb_sysopen - /www.example.com/_site/Category:Category_Name.html
Encoding the colon results in the same error message. I tried:
redirect_from: /Category%3ACloud_Application_Architectures
redirect_from: /Category:Cloud_Application_Architectures
Finally, I included a file Category%3ACloud_Application_Architectures.html in the jekyll page folder. It is added to _site during build, but when browsing to http://www.example.com/Category:Category_Name a "Not Found" error is returned.
Any help would be greatly appreciated! Using a separate webserver with ProxyPass redirection to GitHub handling the redirects in the .htaccess file would only be my last resort. After all, I am trying to get rid of maintaining a server for the site ;-)

Related

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

GitHub Pages (github.io) doxygen generated page not found (404)

I don't understand why a page generated by doxygen can't be found (404).
Its path in the Github repository is https://github.com/AubinMahe/AubinMahe.github.io/blob/master/doxygen/html/dd/dfb/_shareable_8h.html Click here to see
The same page browsed from the root of dcrud documentation site is http://aubinmahe.github.io/doxygen/html/dd/dfb/_shareable_8h.html Click here to see
The same path but... 404! Why? Why this page and not the others?
I've found an answer...
Files that start with an underscore are missing
By default, Jekyll does not build any files or directories that
are hidden or used for backup
(indicated by names that start with . or #, or that end with ~);
contain site content (indicated by names that start with _); or
are excluded in the site configuration.
To work around this behavior, you can
include a .nojekyll file in the root path to turn off Jekyll;
use the include directive in your _config.yml to specify files that
should not be ignored; or
do not use file or directory names that start with an underscore (_),
period (.), or hash symbol (#), or that end with a tilde (~).

GitHub Pages trailing slashes

Using Middleman on GitHub Pages with directory_indexes enabled, I wonder if I can somehow get rid of the trailing slash GitHub adds.
My urls are basically: /foo-bar -> /foo-bar/index.html.
Visiting /foo-bar on GitHub Pages redirects to /foo-bar/.
Is there any way to prevent this redirect?
A "trailing slash" redirect is issued when the server receives a request for a
URL http://servername/foo/dirname where dirname is a directory. Directories
require a trailing slash, so mod_dir issues a redirect to
http://servername/foo/dirname/.
Source
The problem with this is that GitHub pages / Jekyll build the way you have shown
above. To fix this, foo-bar needs to be a file rather than a directory:
http://example.com/foo-bar.html
Then you should be able to do:
http://example.com/foo-bar
ยง Permalinks

Web server keeps displaying Index of / and files (including index.html) returns 404 file not found

There are absolutely no spelling mistakes.
I have index.html in /public_html/ (with necessary .css files etc)
Also in the same folder I have the .htaccess file.
Also to note this was literally working 5 minutes ago, and now my web server is not displaying the index.html or any other file, it just says that it cannot be found with a 404 error message. Also next to the files under the memory size it says 0k, and it says the files were last modified on 31-Dec-1969. What?
What could be going on here?