Need to link to index.html - html

I try to create a bunch of local HTML files that should serve as a documentation for some software. No webserver should be involved, just HTML files viewed by a webbrowser. I use hugo to create the pages, but I have problems linking to the main page (index.html).
My config.toml is this:
#baseURL = "http://example.com"
languageCode = "en-us"
title = "foo"
theme = "mytheme"
relativeURLs = true
canonifyURLs = false
uglyURLs = true
and my main page is _index.md in the root folder.
How do I create a shortcode or whatever that creates a relative link to the index.html in the root folder (content folder in hugo). The index.html page gets created, but I have not succeeded to create a link to that page. Of course I could hard code the link, but this is not what I want.
The sample repository is at https://github.com/pgundlach/hugoexample/ .
I have tried a shortcode with a definition like {{ with .Site.GetPage "section" "_index.md" }}{{ .Relpermalink }}{{ end}} but this didn't work.
Disclosure: This is actually a question I have tried on https://discourse.gohugo.io/ but without any luck. So the question might be "stupid" or I am missing something obvious.

I am also a beginner. However, I think that the index.md file should be in your content directory. Then you should create an index.html file in your layouts directory for rendering the .md file.
Or am I missing what you are trying to do here?
Docs about the directory structure: https://gohugo.io/getting-started/directory-structure/

Related

Jekyll does not create html page from markdown file

I'm new to Jekyll and build a webpage using the TeXt Theme. I downloaded all files and created a local Jekyll website which runs successfully. The project folder contains the folders
_data
_includes
_layouts
_posts
_sass
_site
assets
docker
docs
screenshots
test
tools
The rest of the files in the folder are _config.yml, index.html, etc.
Now let's say I want to create a new page "Bio" that appears as an entry or name in the navigation bar at the top of the website like "about" or "archive".
I create a .md-file in the main project folder (i.e. where index.html lies) and specify in the front matter the layout - in the case of TeXt it is
layout: page
Also, in the _data folder I open the navigation.yml and append under "header" a new title called "Bio", i.e.
header:
title: Bio
url: /Bio.html
This is completely analogue to the about-page that is in the navigation bar and works properly.
But when I do it like this with Bio I get a 404 error and Jekyll is not able to find the site.
I searched all folders of the project and found that Jekyll does not create the necessary.html-file Bio.html on the basis of Bio.md. It just moves Bio.md into _site.
Hence, the url given in the navigation.yml cannot be found and I get the error. How do I get Jekyll to create the Bio.html?
If Bio.md is just copied, that means that Jekyll thinks it's a static file.
You're certainly missing a correct Front matter.
Your Bio.md should look like :
---
layout: page
title: Bio
---
## Content here
...
If problem persists, please add a repository url to help debug.
I figured out the answer myself. It is the notorious UTF-8 BOM issue with Jekyll. The file Bio.md was written in Notepad which uses BOM by default. Using ANSI instead solved the problem entirely without changing anything at the previous front matter.

Can you change the root directory in jekyll

I've been trying to change the root directory of my jekyll site to another folder but I can't seem to find a way to do this and was wondering if it's possible?
What I want is for all of my html pages to be in a folder named _pages, and for my website to load index.html from this folder. Currently I can only get this working by changing the baseurl and accessing the website by www.domain.com/pages/index.hmtl. Can I have it so the html files remain in this folder, and have jekyll render the site so that I can access index.html from www.domain.com/ ?
Thank you
In your _config.yml file you'll need to include the directory where your HTML pages live like this:
include: [_pages]
In your _pages/index.html file include a permalink in the frontmatter like this:
---
permalink: /
---
Run your Jekyll build command again. If I understand your question correctly, this will output your homepage without needing to have or adjust your baseurl.

How do I get the host url in post file?

The question is in jekyll.I put my images resource into assets/images/ folder.And I want to refer this image in my post file.
The site give these solution:
... which is shown in the screenshot below:
![My helpful screenshot]({{ site.url }}/assets/screenshot.jpg)
But how do I know the the host instead of site.url? So it will work fine in local and github page.
It's seems that the site is wrong. Calling an image can be done like this :
![My helpful screenshot]({{ site.baseurl }}/assets/screenshot.jpg)
Don't forget to set your baseurl depending on your hosting.
eg : if your site is at username.github.io/myblog, set baseurl: /myblog
Jekyll is static site generator, destination result of this generator is located on _site folder, on this folder we can find result of assets, css, javascript and html which generated from _post folder. Site is one of the variable to collect Sitewide information and configuration settings from _config.yml. Url can set on _config.yml

Automagic Slug-like links?

I saw a ghpages site that linked to other pages without a .html extension. Is there a way to get this same link working on my local Jekyll?
Ex.
Root folder:
index.md
example.md
My Example Page
On github pages you need an index.html. With Jekyll, an index.md, generated as index.html will also work. With no index.html generated file, you will have a folder listing as a result.
Did you have some example of repository linking to files with no extensions ?
The only way to get a http://host.tld/index link with Jekyll is to set a [permalink][1] on page's front matter : eg for index.html permalink: index/ will generate your page at http://host.tld/index/index.html with http://host.tld/index/ as a shortcut.
The only problem will be that http://host.tld/ will point to nothing except a folder listing. So, you can live index.html alone and put permalinks on all other pages.

Jekyll: All HTML files in /folder, now forced rendering through /folder/page/. How to change?

So I've tried looking here:
http://jekyllrb.com/docs/permalinks/
and here:
Show pages under one folder in Jekyll?
But this doesn't seem to resolve my issues.
So here is the situation:
Initially, I had all my Jekyll *.html files living in the /root folder of where I am running Jekyll, this was a bit messy, as there was over 30 *.html files, but when I did this:
jekyll build
jekyll serve
I would get the site propagating to: http://0.0.0.0:4000/
I now moved all the *.html files to a folder called /html (within the project root). When running:
jekyll build
jekyll serve
My site no longer renders at: http://0.0.0.0:4000/
But it renders at: http://0.0.0.0:4000/html/
I would like to remove the /html part of the URL, but as the above 2 links show, there was no previous question related to this.
Can anybody suggest how I can remove the /html part from my URLs?
Okay, so initially your folder structure looked like this, correct?
/_layouts/default.html
/css/whatever.css
/index.html
Now to your question:
Do you want to move the HTML files and nothing else to the html subfolder?
In other words, do you want to do this?
/_layouts/default.html
/css/whatever.css
/html/index.html
If yes, read David Jaqcuel's answer.
If not, continue reading my answer :-)
Or is it just that you don't want all your source files cluttering up your root folder?
If yes, you could move everything into the html subfolder, like this:
/html/_layouts/default.html
/html/css/whatever.css
/html/index.html
Then you need to tell Jekyll that the html folder is the root folder for the site's source files.
To do so, you need to add the following line to the config file (or create the file if it doesn't exist yet):
source: html
Important: the config file needs to be in the root folder of your project, even if you move your source files into a subfolder!!
Then all your source files are in the html subfolder, but the generated site will look like this:
/_layouts/default.html
/css/whatever.css
/index.html
In other words, the URL will still be http://0.0.0.0:4000/.
If you want to see an example, you can look at the source code of my blog:
I'm doing exactly the same there, only that the folder with the source files is called src.
By default, for pages in /html, Jekyll will generate a page like /html/page.html and so on.
I think you cannot add a permalink front matter default for a folder, you'll be obliged to set a permalink for each page you put in /html.
eg : for html/page.hmtl, you'll have to set :
---
permalink: page.html
---
This is the way without plugin. Otherwise, you can do it with a Generator plugin that will take all your pages in /html and change the all the target permalink.