-
Notifications
You must be signed in to change notification settings - Fork 73
Adding New Posts
In the Jekyll template system new content is often referred to as posts
.
This historically happened because Jekyll is a solution consistently used for blogging apps.
The posts
terminology even influences
what happens at the directory level. All new content ( think pages )
are stored in date specific files within the _posts
directory off of the project root.
So below when we talk about creating new posts
just think new pages.
This exercise will assume that i want to add a new event to the CUGOS website for July 23, 2013. The fact that what i'm adding is an "Event" is arbitrary. The workflow described below applies to adding new Meetings, People, Blog Entries and Projects
We are assuming that you've checkout out the CUGOS github project locally. If you navigate
to the root directory of that project and type ls -lah
you should see a list of files
and directories like the ones below. The only directory we care about for this workflow
is the _posts directory:
gcorradini@twinkie:/usr/local/src/cugos_website$ ls -lah
total 116K
drwxrwxr-x 18 gcorradini gcorradini 4.0K May 30 13:21 .
drwxr-xr-x 40 gcorradini dev 4.0K Jul 17 14:36 ..
-rw-rw-r-- 1 gcorradini gcorradini 1.4K Mar 11 11:01 404.html
drwxrwxr-x 2 gcorradini gcorradini 4.0K Mar 11 11:01 about
-rw-rw-r-- 1 gcorradini gcorradini 557 Mar 11 11:01 archive.html
drwxrwxr-x 2 gcorradini gcorradini 4.0K Jun 16 14:07 blog
-rw-rw-r-- 1 gcorradini gcorradini 9 Mar 11 11:01 CNAME
-rw-rw-r-- 1 gcorradini gcorradini 1.3K May 30 13:21 _config.yml
drwxrwxr-x 2 gcorradini gcorradini 4.0K Mar 11 11:01 contact
drwxrwxr-x 4 gcorradini gcorradini 4.0K Mar 11 11:01 css
drwxrwxr-x 2 gcorradini gcorradini 4.0K Mar 11 11:01 events
-rw-rw-r-- 1 gcorradini gcorradini 318 Mar 11 11:01 favicon.ico
-rw-rw-r-- 1 gcorradini gcorradini 512 Mar 11 11:01 feed.xml
drwxrwxr-x 8 gcorradini gcorradini 4.0K Jul 21 15:44 .git
-rw-rw-r-- 1 gcorradini gcorradini 13 Mar 11 11:01 .gitignore
-rw-rw-r-- 1 gcorradini gcorradini 14 Mar 11 11:01 humans.txt
drwxrwxr-x 4 gcorradini gcorradini 4.0K Mar 11 11:01 image
drwxrwxr-x 2 gcorradini gcorradini 4.0K May 29 16:18 _includes
-rw-rw-r-- 1 gcorradini gcorradini 1.9K May 30 13:17 index.html
drwxrwxr-x 4 gcorradini gcorradini 4.0K Mar 11 11:01 js
drwxrwxr-x 2 gcorradini gcorradini 4.0K May 30 11:15 _layouts
drwxrwxr-x 2 gcorradini gcorradini 4.0K May 30 11:13 meetings
drwxrwxr-x 3 gcorradini gcorradini 4.0K Jul 11 08:43 people
drwxrwxr-x 8 gcorradini gcorradini 4.0K Mar 11 11:01 _posts
drwxrwxr-x 3 gcorradini gcorradini 4.0K Mar 11 11:01 presentations
drwxrwxr-x 2 gcorradini gcorradini 4.0K Mar 11 11:01 projects
-rw-rw-r-- 1 gcorradini gcorradini 91 May 27 15:57 README.md
-rw-rw-r-- 1 gcorradini gcorradini 32 Mar 11 11:01 robots.txt
drwxrwxr-x 14 gcorradini gcorradini 4.0K Jul 11 11:12 _site
gcorradini@twinkie:/usr/local/src/cugos_website$
Now let's navigate to the _posts
directory and see what's there:
gcorradini@twinkie:/usr/local/src/cugos_website/_posts$ ls -lah
total 32K
drwxrwxr-x 8 gcorradini gcorradini 4.0K Mar 11 11:01 .
drwxrwxr-x 18 gcorradini gcorradini 4.0K May 30 13:21 ..
drwxrwxr-x 2 gcorradini gcorradini 4.0K Jul 21 15:44 blog
drwxrwxr-x 2 gcorradini gcorradini 4.0K Jul 21 15:43 events
drwxrwxr-x 2 gcorradini gcorradini 4.0K Jul 21 15:44 meetings
drwxrwxr-x 2 gcorradini gcorradini 4.0K Jul 11 08:46 people
drwxrwxr-x 2 gcorradini gcorradini 4.0K Mar 11 11:01 presentations
drwxrwxr-x 2 gcorradini gcorradini 4.0K Mar 11 11:01 projects
gcorradini@twinkie:/usr/local/src/cugos_website/_posts$
Now we can see where to create new content for multiple parts of the website. Let's focus on creating a new "Event" since that's the example for this workflow.
Navigate into the events
directory and copy the most recent dated post in there to a new file with
the date you are creating an event for. For example, I will take the most recently dated file and
copy it to a file dated 2013-07-23-<blah blah description>.markdown
:
$ cp _posts/events/2013-05-22-foss4g-na.markdown _posts/events/2013-07-23-mappyhour.markdown
Using your favorite editor flavor ( go VIM! ) edit your new file and replace all the previous content with your new content!
Now it's time for the GIT workflow. Assuming that you have rights to push to the CUGOS repo, then do the following. If you do not, then make sure you e-mail Aaron, Matt K or Greg to get them. You can also fork the repo into your workspace and push changes there and send pull request. But that's a lot more work!
# add the new file
$ git add _posts/events/2013-07-23-mappyhour.markdown
# add a commit message
$ git commit -m "Whoo hoo. Added mappyhour content"
# ahh just push it, push it good
$ git push