Comments (2)
Wow Hemang! Thank you so much for the thorough response! I definitely understand everything better now, and will start playing around with things to customize the website a bit for myself. I'll let you know if I hit any hiccups now 👍
from gravity.
Hello @sjfox 😄
Thanks for getting in touch,
Let me give you a complete overview of things,
In the Includes folder,
- There is a file called head.html which contains all the stuff that goes into the tag of each webpage generated with Gravity.
- Header.html consists of all the code driving the header part of website. Like the title, description and navigation bar.
In the layouts folder are the basic templates for,
- Creating a page
- Creating a post
- Creating an archive page
Post folder contains all the posts, as its name.
Now as you can see there are several files in main directory which are not inside any folder, config.yml, about.md, design.md, index.html etc.
So the about.md and download.md files, are sample Pages, whereas design.md and science.md are sample Archive Pages (Archive Pages show only those posts which fall under their category ).
But as you can see the archive.html file in layouts folder, it has..
---
layout: page
---
This implies that all archive type pages are ultimately of type page only. This type thing decides what kind of layout that .md file should be given.
So let me show how navigation files are generated. Two things to keep in mind are, header.html is the file which contains all the contents that go into the header part of all the webpages generated using Gravity and the second thing is FRONT MATTER decides what file is what.
Process of page creation
- We create a file called newpage.md in root directory and in its front matter write,
layout: page
title : Give a title, lets say 'newpage'
permalink: Give a permalink (Usually the title), lets say /newpage/
---
- Now save the file.
- Jekyll starts generating webpages, it checks the value in the layout field of newpage.md, searches for that layout name in _layouts folder, and then applies that layout to our newpage.md and converts it into newpage.html. This all happens under the hood.
- Jekyll starts processing header.html and starts creating content to be put in header part of website.
- Jekyll reaches this part of code in header.html, this part is responsible for creating navigation bar,
<div class="trigger site-navigation">
<a class="page-link" href="{{site.url}}{{site.baseurl}}">HOME</a><span class="exclamationMark">/</span>
{% for sitePage in site.pages %}
{% if sitePage.title %}
<a class="page-link" href="{{sitePage.url | prepend: site.baseurl }}">{{sitePage.title}}</a><span class="exclamationMark">/</span>
{% endif %}
{% endfor %}
</div>
The first part
<a class="page-link" href="{{site.url}}{{site.baseurl}}">HOME</a><span class="exclamationMark">/</span>
is a hardcoded link to HOME page.
And the second part
We have a FOR loop (Language used: Liquid).
This searches all the generated webpages which have a layout of type "page" and then display them in site's navbar in ALPHABETICAL ORDER.
{% for sitePage in site.pages %}
{% if sitePage.title %}
<a class="page-link" href="{{sitePage.url | prepend: site.baseurl }}">
{{sitePage.title}}
</a>
<span class="exclamationMark">/</span>
{% endif %}
{% endfor %}
So its the property of Liquid's for Loop due to which all the navigation pages are arranged in Alphabetical Order by default.
You can read more about for loops in Liquid and modify them, like reversing the order of pages and limiting the number of pages
https://github.com/Shopify/liquid/wiki/liquid-for-designers
https://help.shopify.com/themes/liquid/objects/for-loops
https://help.shopify.com/themes/liquid/tags/iteration-tags
Like here's how we can modify the for loop so that it shows only 5 pages in navigation bar,
{% for sitePage in site.pages limit:5 %}
Feel free to discuss more/ask anything. 👍 😃
Thanks
Hemang
from gravity.
Related Issues (20)
- How to add icon HOT 7
- Center pages under title
- Unable to install jekyll on Ubuntu16.04 HOT 4
- Does it support timeline in the archive layout? HOT 2
- Your theme is listed on jekyll-themes.com
- post.excerpt not work in chinese HOT 6
- How to change font size HOT 3
- Filter homepage posts HOT 3
- Hosting fonts locally? HOT 7
- blank entries on home page HOT 7
- how to make design.md homepage
- You can look at my changes HOT 6
- How do you change the order of the pages on the main navigation? HOT 3
- Add coafile HOT 16
- Create a dark theme for Gravity HOT 3
- Website not picking up my latest post HOT 2
- Github page does not exist. HOT 2
- Post Title turning red? HOT 9
- How to build up this theme with Github Page? HOT 4
- Refactor Plan
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gravity.