0
votes

I'm new to Jekyll and having trouble setting it up the way I want. I have a site already with a standard directory structure: css, img and js directories and and index and page html files on the same level. So far so normal.

If I run jekyll new blog, it sets up the files it needs in a subdir blog. But then when I go to that directory to change the basic layout files and do jekyll serve, it builds fine, it can't find the css files that are valid for my whole site - because it can't "see" anything in a directory further up. I've tried messing with the path to the css, but I don't seem to be able to make it show up. I tried moving everything from the subdir "blog" up one level, so that the _layoutsb folder etc are on the same level as the css and img directories, but then I have the problem that Jekyll builds an "index.html" file only - I don't want that, I already have an index file, and it's a .php, not a .html.

How can i either: a.) get Jekyll running in a subdir but use the css styles, images etc from the main css dir

or

b.) get jekyll to live on the top level dir but build do something that is not "index.html"??

Thanks for any help. I keep building, deleting and tweaking and making no progress at all.

1

1 Answers

0
votes

Well, Jekyll is a static website generator and does not support php. But you can do almost everything with Liquid Templating Language, like includes and you can use tons of functions, filters and other features that allow you to write dynamically and publish static pages.

Good news, though: I've found a workaround to include php files! ;)

  1. Create a folder in the site root. Let's say it's name is php (without the underscore). Add there as many php files as you want. Let's assume you have included an index.php inside php dir.

  2. In you _config.yml, add this line:

    keep_files: [php]
    

This will let the folder php untouched when Jekyll build the site.

  1. Run jekyll serve as you normally would.

  2. When you add the link to the stylesheets (and other links), don't forget that the folder containing your php files will be at the same level as your css folder, so do that in your index.php:

    <link rel="stylesheet" href="../css/main.css">
    
  3. To see the php files taking effect, you'll need to build the site in your localhost root. For example, if you use Xampp, it will be inside of htdocs. To see the files, you'll need to turn Apacheon and type in the browser: http://localhost/test/_site/php/ - where test is the project root folder - and you'll see your index.php working as it should. The other files will be available via _site and also via localhost:4000.

  4. Upload to your web server the _site content only, unless your server builds Jekyll automatically.

Open the _site folder to check how your website was build.

Don't forget: you won't be allowed to host your site on GitHub Pages as it's doesn't offer support to php. I'd recommend you to host your site in a full-featured hosting provider.

Hope to have helped!