I am trying to setup a template Jekyll project with the structure below. The goal is to reuse all markdown files in the project while being the least intrusive, keeping all custom layouts and configurations in a single folder.
.
├── README.md # some new project file stay in the roots
├── about.md # some new project file stay in the roots
├── docs # folder containing pages
│ └── assets
│ └── index.html # generated from README.md
│ └── about.html # generated from about.md
│ └── ...
├── jekyll # folder containing all jekyll specific files
│ └── _layout
│ └── assets
│ └── _config.yml
│ └── ...
To make this work, I'm running Jekyll from the /jekyll folder using the following configurations.
theme: jekyll-theme-cayman
source: ./..
destination: ./../docs
include:
- "./_layout"
- "./assets"
exclude:
- "./"
Here comes my problem: when I do this Jekyll ignores my custom layout. Could anyone help me understanding this problem?
P.S.: I'd prefer not to publish my custom layout as a new theme entirely.
Related
I'm trying to reach some of my css files but I can't seem to get the directory right.
For example I have a link in my home.html:
<link href="assets/plugins/revo-slider/css/settings.css" rel="stylesheet" type="text/css"/>
I've converted it to:
<link href="{% 'assets/plugins/revo-slider/css/settings.css' %}" rel="stylesheet" type="text/css"/>
But that's the incorrect directory because I recently moved the file to where it is now as shown below.
my folder structure is as follows:
project/
├────── Index/
│ ├──_static/
│ │ ├── css/ (.css files)
│ │ ├── js/ (javascript files)
│ │ ├── img/ (images files)
│ │ ├── media/ (video files)
│ │ └── plugins/ (.css plugin files)
│ │
│ └── templates/
│ └── index/
│ ├── home.html
│ └── about.html
├── manage.py
└── project folder with settings.py,url.py
my settings.py includes:
line 5: BASE_DIR = Path(__file__).resolve().parent.parent
line 90: STATICFILES_DIRS = [
"/index/static",
]
I've checked the similar questions and youtube tutorials but I've seen some which suggested I add:
os.path.join(BASE_DIR, 'static')
in line 91 but i've seen conflicting codes through Youtube tutorials, first step is getting the directory right in my html though, if anyone can help it'd be great
First of all, don't specify your static files directory (in line 90 in your case). If you use the name static for your directories, Django automatically discovers them. You can get rid of that entire line. Just be sure to use static name for your directories always.
For some reason if you want to specify your static directories, just use the directory name, don't specify the path. i.e.:
STATICFILES_DIRS = [
"/index/static",
]
should be:
STATICFILES_DIRS = [
"static",
]
Secondly, you should always namespace your static file directories. For example, in the static directory of each app, first, create a directory with the same name as the app name and keep your static files in there. This will let you use different static files even with the same names without any conflicts. Here is my suggested structure.
.
├── manage.py
├── my_app
│ └── static
│ └── my_app
│ ├── css
│ │ └── style.css
│ └── js
│ └── script.js
├── project
│ └── settings.py
└── static
And in your templates, you can use static files like this:
<link rel="stylesheet" href="{% static 'my_app/css/style.css' %}">
In development, Django will automatically discover your static files. And before pushing the project live in production, run python manage.py collectstatic and your static assets will be copied to the static directory in the project root. To make this work, you need to specify the static root path so Django will copy static assets from each app to the root static directory. Add this to your settings.py file:
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
This is what I always do. I find this to be a cleaner way to manage static assets as each of your apps can have independent static files and by namespacing your static directories, you will be able to avoid conflicts.
Okay I've figured it out, I just removed the 'assets' tag from the directory link but can someone double check I have the correct code in my STATICFILES_DIRS please, I've seen conflicting answers I have the latest version of django
I am trying to build a web application running wasm on the client side, and I am wondering what would be a good way of serving multiple pages.
My main concern is performance, because I would like to split the application up into contextual chunks instead of having one page with all of the content.
I am using Rust with the Yew framework for the client side, and so far I have only used yew_router to handle different routes on the client side, but they all work from the same HTML page and Wasm module. Now I would like to be able to serve different HTML pages with separate Wasm modules, and I am unsure how to realize this. Do I really have to write a dedicated crate for each page and compile those to individual Wasm modules, so I can serve them individually? Or is there some way I can compile one rust crate to multiple Wasm modules?
My current project structure looks like this:
.
├── Cargo.toml // workspace manifest
├── client
│ ├── Cargo.toml
│ ├── favicon.ico
│ ├── index.html
│ ├── main.js
│ ├── Makefile
│ ├── pkg // built using wasm-pack and rollup
│ │ ├── bundle.js
│ │ ├── client_bg.d.ts
│ │ ├── client_bg.wasm
│ │ ├── client.d.ts
│ │ ├── client.js
│ │ ├── package.json
│ │ └── snippets
│ ├── src
│ ├── statics
│ ├── styles
│ └── vendor
├── server
│ ├── Cargo.toml
│ └── src
└── ... other crates
and I run the server inside client/ where it responds with index.html to any incoming GET requests. The index.html links to the bundle.js in pkg/ which sets up the client_bg.wasm module.
Now I basically want to do this with another HTML page, with another Wasm module, preferably from the same Yew App in the client crate.
Thank you
Currently it's impossible to generate two wasm files from one crate. The solution is to use one create per wasm file and then let another build system to put output to correct places.
I'm trying to accomplish the task of linking to files within a collection from a post on a Jekyll site. However, I'm having an issue that relates to the collection having subdirectories, and those subdirectories having spaces in their names.
Here's a simplified example of how my site source is layed out:
├── 404.html
├── about.md
├── _config.yml
├── Gemfile
├── Gemfile.lock
├── index.md
├── _labs
│ └── Lab 01 Introduction
│ └── PS01 source.html
├── _posts
│ └── 2020-01-01-test_post.md
The post 2020-01-01-test_post.md contains the following markdown:
---
layout: post
title: "Introduction"
author: "Will Hopper"
---
[Link]({{ site.baseurl }}{% link _labs/Lab 01 Introduction/PS01 source.html %})
So far so good, and running jekyll serve succeeds just fine, meaning it can find the linked file at build time. The issue arises later, with the way jekyll has handled the spaces in the Lab 01 Introduction directory. Here is the contents of the _site folder after building:
└── _site
├── 404.html
├── about
│ └── index.html
├── assets
│ ├── main.css
│ └── minima-social-icons.svg
├── feed.xml
├── index.html
├── labs
│ └── Lab%2001%20Introduction
│ └── PS01 source.html
└── posts
└── test_post.html
As you can see, the spaces in the filename have been replaced with the URL encoded escapes, %20. As a result, the link in the post 404's.
I tried replacing the "raw" name of the folder with the URL encoded output, i.e., I tried {% link _labs/Lab%2001%20Introduction/PS01 source.html %} but now the site fails to build with Liquid Exception: Could not find document.
This HTML file is effectively a static file (i.e., it has no front matter). And curiously, Jekyll seems to leave spaces in the filenames alone!
Any ideas on what I could do to stop the spaces in my directory names from being URL encoded when the site is built?
I have the following file structure in my Jekyll project:
├── _articles
│ ├── bar
│ │ └── widget.md
│ ├── bar.md
│ └── phone.md
└── foo.md
See here: https://github.com/janpio/jekyll-test
_articles is a collection that is defined in _config.yml:
collections:
articles:
title: Articles
output: true
permalink: :path
On Github Pages this is built into these URIs:
https://janpio.github.io/jekyll-test/bar/widget
https://janpio.github.io/jekyll-test/bar
https://janpio.github.io/jekyll-test/phone
https://janpio.github.io/jekyll-test/foo/
See here: https://janpio.github.io/jekyll-test/
That is all fine and as expected.
But when I bundle exec jekyll s this project locally1 it doesn't work the same way. I get the expected URIs:
http://127.0.0.1:4000/bar/widget
http://127.0.0.1:4000/bar
http://127.0.0.1:4000/phone
http://127.0.0.1:4000/foo/
But the problem is that #2 gets redirected to 127.0.0.1:4000/bar/ and shows a directory listing instead of the actual page!
Looking at _site this is the file structure that is generated:
├── bar
│ └── widget.html
├── bar.html
├── foo.html
├── index.html
└── phone.html
So I can access bar.md at http://127.0.0.1:4000/bar.html.
How can I fix this?
1 My Gemfile is so the environment should be identical to Github Pages: https://github.com/janpio/jekyll-test/blob/master/Gemfile
Update for Jekyll 3.6.x
The 3.6.0 Jekyll release changed this behaviour:
Fix serving files that clash with directories (#6222) (#6231)
Unfortunately, these changes didn't really fix the problem but replace it with a less serious one: The link now doesn't show the directory listing any more but the correct page, but the path is still different in that it adds the / at the end. Unfortunately as a regression bar/widget doesn't render the correct content any more but shows bar.md.
These are the first solutions that come to my mind:
Stop using 'pretty URLs'
Use only index.md files (each of them in a seperate folder)
Prevent naming collisions between folders and files
Create an index.html file in the bar folder that redirects to bar.html (although that might create a redirect loop)
Update for Jekyll 3.7.x
The 3.7.0 Jekyll release included a PR that should fix this problem:
return correct file in dir if dir has same name as file
I have a Jekyll blog and some of the raw posts have some additional files at the same level with the markdown file. For example:
.
├── _posts
├── first-post
├── 2007-10-29-first-post.md
└── download.zip
How can I and up with a generated structure such as
.
├── _sites
├── first-post
├── index.html
└── download.zip
The download.zip file needs to be in the same location as its dependent post (I cannot use any includes or other redirect tricks)
Try this jekyll-postfiles which is:
A Jekyll plugin that copies static files from the _posts to the _site folder