How to fix Jekyll Baseurl problems - jekyll

I'm making a theme for Jekyll, and I've hit a problem where the site only serves to localhost:4000, and when I add a baseurl, it ignores it, although the command line output says it is serving it to localhost:4000/baseurl/. The theme is on GitHub here.
Any help much appreciated!

Should be fixed when you use {{ page.url | prepend: site.baseurl }}.

It was a Windows problem. See https://github.com/forgenst/jekyll-statuspage/issues/3

Related

How to set up permalinks with variables in jekyll?

I'm trying to setup jekyll so that it will automatically create permalinks for new posts but it's not working.
What I did is setting a variable in the _config.yml like this:
permalink: /:title/
then, in a loop of post previews on the homepage I created a link like this:
Read More
Expecting the output to be something like.
Read More
and instead I'm getting this:
Read More
which if I click gives a 404 Not Found error.
What am I doing wrong?
For more info here is the github repo.
Thanks!
Matteo
As #David Jaquel suggested I solved by using
{{ site.baseurl }}{{ post.url }}

Jekyll on GitHub Pages: permalinks don't include baseurl

I'm working through a guide for setting up Jekyll on GitHub Pages. My GitHub repo publishes to ~.github.io/hello-pages, so naturally I'm plugging {{ site.baseurl }} into anchor tags, etc. That's working great.
What isn't working is permalinks: I have to manually spell out permalink: /hello-pages/blog/:year/:month/:day/:title.html in _config.yml for any of the permalinks to work; otherwise they link to e.g. ~.github.io/blog/x/y/z instead of ~.github.io/hello-pages/blog/x/y/z like I expect.
Manually specifying baseurl: /hello-pages has no effect (I suppose GitHub's Jekyll config already does that).
Manually typing "/hello-pages" anywhere seems like quite a rigid design that I'd like to avoid. An older SO answer says that permalinks should "just work". What gives?
Edit
I am constructing the broken URLs like this:
<a href="{{ post.url }}">
I just figured out what I was doing wrong. I need to do one of the below things. Here is documentation about this: https://jekyllrb.com/docs/templates/#filters
<a href="{{ post.url | relative_url }}">
This turns the URL into a relative URL, taking the base URL into account.
<a href="{{ post.url | absolute_url }}">
Same as the above, but makes absolute URLs.
<a href="{{ post.url | prepend:site.baseurl }}">
Prepends the base URL to the permalink.

Could not get disqus to work with jekyll and git pages

I am using Github Pages and Jekyll. I added the Disqus configuration but it could not appear on the posts.
I added disqus.html in the _includes directory. and added my disqus shortname into _config.yml.
Called {% include disqus.html %} from _layout/post.html.
Tried the comment:true option in the markdown files as well.
You may view my work at:
https://github.com/motleis/weekActivities
Thank you for your help.
EDIT: So far, I tried to converge the problem and noticed that {% if site.disqus %} is not evaluated to true. The only thing I can think of is filling the 'disqus' parameter in the _config.yml.
Any other things?
Finally I figured this out!!
"put your short-name inside quotation marks!"

Use Jekyll without Jekyll server / without root directory

I just started using Jekyll today, and I'm trying to figure out how to use it to create a portable static site. Specifically, I want to be able to access the site without using the Jekyll server.
This answer says that this isn't possible, however, it's a couple years old, and it seems like a static site generator should be able generate a site which doesn't need a server to function (can be accessed through the browser as a file file:///...)
The Jekyll docs say that a Jekyll site can be deployed on a remote server by placing the _site/ folder in the web server's root directory. How do I force Jekyll to use relative links, so that I can run the built site from a directory other than the root?
I'm worried that the answer to this question is "it's not possible", or at least "it's not possible without some trickery". I've used Wordpress in the past, and it's trivial to set up a wordpress installation in any directory on a LAMP server. I feel like there has to be some easy way to do this with Jekyll, but I can't find the answer anywhere.
This answer is still valid. But I must admit that it's not really portable to tweak baseurl. You cannot always guess the correct path.
Let's try to make it run on the file system with relatives urls like ./path/to.
What do we need to tweak
Examining the index page, sitting at file:///path/to/_site/index.html, we can identify some potential problems :
styles are not working
posts are linked like file:///jekyll/update/2016/08/05/welcome-to-jekyll.html following the /:categories/:year/:month/:day/:title.html permalink pattern. And we know the folder hierachy is a nightmare when using relative links.
pages. The only one is about with an already defined permalink pointing to /about/ which will not work from file system, because it resolves to file:///about/
In order to avoid folder hierachy hell, we will make every post and page to be created at the root.
Redefining permalinks
In _config.yml we add :
defaults:
-
scope:
type: "posts"
values:
permalink: :slug:output_ext
-
scope:
type: "pages"
values:
permalink: :basename:output_ext
Now any post is generated at the root.
But this about page is still generated in an about folder. Why ?
Because front matter permalink overrides default configuration. We remove permalink: /about/ from about.md front matter and now our page is generated at the root /path/to/_site/about.html. Good !
Rewriting links
We're now making our links relatives to root using the ./ expression.
_includes/head.html
<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">
becomes
<link rel="stylesheet" href="{{ "./main.css" }}">
_includes/header.html
<a class="site-title" href="{{ site.baseurl }}/">{{ site.title }}</a>
becomes
<a class="site-title" href="./index.html">{{ site.title }}</a>
And
<a class="page-link" href="{{ my_page.url | prepend: site.baseurl }}">{{ my_page.title }}</a>
becomes
<a class="page-link" href="./{{ my_page.url }}">{{ my_page.title }}</a>
index.html
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
becomes
<a class="post-link" href="./{{ post.url }}">{{ post.title }}</a>
And you can now navigate.
Remember to keep everything a the root and it will be ok.
I had a problem running Jekyll without the server and was able to resolve it by removing the permalink configuration from the theme I was using (removed the permalink: line from _config.yml). Also had to make sure all non-post URLs use absolute file path (like about and contact).

Is there a way to get the full path of the markdown post in jekyll?

I created a blog just for my personal use. Just to organize my own notes.
Unlike a proper blog where after you write the post you are usually done. I will be editing these post frequently, so in the footer I want to have the following:
sublime /path/to/_posts/markdown-post.md
So that I copy it and paste it in my terminal.
So is there a way to get all that information dynamically. Or at least the full markdown file name (I could hard code the path myself)
{{ site.source }} will give you absolute path to your site root.
{{ page.path }} will give you page path relative to site root.
Finally subl {{ site.source }}/{{ page.path }} will do the trick.