4

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?

Community
  • 1
  • 1
Joe
  • 3,120
  • 3
  • 25
  • 30

2 Answers2

2

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.

Community
  • 1
  • 1
Christian Specht
  • 35,843
  • 15
  • 128
  • 182
1

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.

David Jacquel
  • 51,670
  • 6
  • 121
  • 147