About
Firm is a blog-aware, static site generator written in F#.
Features
It supports stand-alone pages, blog posts, rss, tags (tag cloud) and post archive. Templates are written in Razor. Posts and pages are written in Markdown.
Getting started
- Fork the project at https://github.com/andagr/Firm.
- Clone it to a local directory.
Create the folders
data\templates\razorand add the following template files:1: 2: 3: 4: 5:
archive.cshtml index.cshtml page.cshtml post.cshtml _layout.cshtml
The names should hint at what they should do, and if you need some inspiration then look in the data branch of this repo.
Creating your first blog post
To write your first blog post, create the directory
data\input\blog\post\<name-of-blog-post>and add the following files:1: 2:
index.md meta.json
Open meta.json and add data about the post, example:
1: 2: 3: 4: 5:
{ "title": "Hello", "date": "2015-05-28 21:14:00", "tags": [ "blog", "hello" ] }- Open
index.mdin your favorite Markdown editor and write a post. - Open
config.jsonin the Firm root directory and changebaseUrltohttp://locahost:8080. Also take this moment and change the other settings to your liking. - Open a console in the root directory of Firm and type:
firm generate. Dependencies should now be downloaded, project built and web site generated into the folderoutput. - In the console, run
firm preview, verify that the site looks good and then hit[Enter]in the console to exit preview mode. - Open
config.jsonagain and changebaseUrlto the root url of your site, if it's on GitHub Pages (see publishing below) then it's most likely http://(user).github.io/Firm. - Open a console in the root directory of Firm and run
firm regenerate. Please note that it'sregenerate, notgenerate, Firm will only generate new content for the latter command, and we want to generate everything again to make sure that url's are updated correctly. - Don't forget to add, commit and push the changes to your repository.
- The
datafolder is ignored by default, you can open.gitignoreand remove the entry, it's at the very bottom of the file. - The
outputfolder is also ignored by default, you can either remove the entry or follow the instructions for publishing to GitHub Pages below.
- The
Publishing to GitHub Pages
There are many different hosts for static websites, but in this guide I will refer to GitHub Pages. Please note that in this case I refer to GitHub Pages for project sites.
One time setup
Open a console in the root directory of Firm and create a new branch:
1: 2:
git branch gh-pages git checkout gh-pages
- Delete everything except the
outputdirectory. - Move the content of the
outputdirectory to the root directory of Firm. - Delete the now empty
outputdirectory. Stage, commit and publish/push the changes:
1: 2: 3:
git add -A * git commit -m "Created first blog post!" git push --set-upstream origin gh-pages
Switch back to the master branch:
1:git checkout master
Now here's the trick, we want to store the
gh-pagesbranch in theoutputdirectory, so that when we create a new post we can simply move into that directory and push the changes directly to the correct branch. In a console in the root directory of Firm, clone thegh-pagesbranch into theoutputdirectory:1:git clone -b gh-pages https://github.com/(user)/Firm.git output
Creating a repeatable workflow
- Add or edit a post or page.
- Change config.json:baseUrl to http://localhost:8080.
- Run
firm regenerateto generate your site in theoutputfolder. - Run
firm previewand verify that it looks ok. - Change back config.json.
- Run
firm regenerateagain. - Add, commit and push changes on both your
masterandgh-pagesbranches.
You're done! All you have to do from now on is create content, verify that it looks ok and then push it to GitHub Pages.
Happy blogging!
Thanks to
- FsBlog - For the idea.
- FSharp.Formatting - Markdown parsing and code formatting.
- RazorEngine - Templates.
- FAKE - Building and general tool.
- FSharp.Data - JSON parsing.
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.set