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

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

Related

Using default Hugo theme content through Netlify produces blank webpage, but works locally. blogdown

I have found the same/similar question to mine here: Create a new static page using blogdown with same hugo theme as main site but I cannot understand what the solution is as there seems not to be one explicitly, or I just do not grasp it.
I am an absolute beginner. I am testing the procedure to move generated code to netlify to produce a website.
I can put the public/post/2020-12-01-r-rmarkdown/index.html file into public/ folder in github and generate the example site on netlify e.g.:
https://github.com/hjhjonas/blogsite/tree/main/public produces
https://elastic-ptolemy-e2ba86.netlify.app/
However I plan to edit the default theme and use that instead. But the default index.Rmd file that produces the index.html file after i edit the yaml files and content files to use is like this:
https://github.com/hjhjonas/blogsite/blob/main/index.html
and produces a blank page on netfify.
But if I knit from Rstudio and serve_site() locally, it looks like this image attached, which is correctly what I need.
What I want to do is edit this original theme/layout and put the generated html into the public folder in github for Netlify to read.
The index.Rmd file that produces this local site is just
---
site: blogdown:::blogdown_site
---
I previous had a 404 error on netlify and followed these steps to realise that the html is required for Netlify to produce the deploy the page:
https://answers.netlify.com/t/support-guide-i-ve-deployed-my-site-but-i-still-see-page-not-found/125
This is the theme that I would like to use https://themes.gohugo.io/themes/hugo-lodi-theme/
I don't know how you generated the public/ folder, but it is not meant to be generated by manually copying or moving any files to it. If you publish a site via Netlify, there is no need to generate the public/ folder locally at all, because it can be automatically generated on Netlify.
First, delete index.html in the root directory, and please do not knit index.Rmd again in the future. Second, delete the public/ folder. After the two deletions, I think your site should appear on Netlify soon. If not, see if blogdown::check_site() has any recommendations.

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

Jekyll: Redirect from URLs containing colons

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 ;-)

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.