An easy to use blogging platform with extra features for Jupyter Notebooks.
We are very pleased to announce the immediate availability of fastpages. fastpages
is a platform which allows you to create and host a blog for free, with no ads and many useful features, such as:
fastpages relies on Github pages for hosting, and Github Actions to automate the creation of your blog. The setup takes around three minutes, and does not require any technical knowledge or expertise. Due to built-in automation of fastpages, you don't have to fuss with conversion scripts. All you have to do is save your Jupyter notebook, Word document or markdown file into a specified directory and the rest happens automatically. Infact, this blog post is written in a Jupyter notebook, which you can see with the "View on GitHub" link above.
fast.ai have previously released a similar project called fast_template, which is even easier to set up, but does not support automatic creation of posts from Microsoft Word or Jupyter notebooks, including many of the features outlined above.
Because fastpages
is more flexible and extensible, we recommend using it where possible. fast_template
may be a better option for getting folks blogging who have no technical expertise at all, and will only be creating posts using Github's integrated online editor.
The setup process of fastpages is automated with GitHub Actions, too! Upon creating a repo from the fastpages template, a pull request will automatically be opened (after ~ 30 seconds) configuring your blog so it can start working. The automated pull request will greet you with instructions like this:
All you have to do is follow these instructions (in the PR you receive) and your new blogging site will be up and running!
The first cell in your Jupyter Notebook or markdown blog post contains front matter. Front matter is metadata that can turn on/off options in your Notebook. It is formatted like this:
# Title
> Awesome summary
- toc: true
- branch: master
- badges: true
- comments: true
- author: Hamel Husain & Jeremy Howard
- categories: [fastpages, jupyter]
All of the above settings are enabled in this post, so you can see what they look like!
>
) will be displayed under your title, and will also be used by social media to display as the description of your page.toc
: setting this to true
will automatically generate a table of contentsbadges
: setting this to true
will display Google Colab and GitHub links on your blog post.comments
: setting this to true
will enable comments. See these instructions for more details.author
this will display the authors names. categories
will allow your post to be categorized on a "Tags" page, where readers can browse your post by categories.Markdown front matter is formatted similarly to notebooks. The differences between the two can be viewed on the fastpages README.
put a #collapse-hide
flag at the top of any cell if you want to hide that cell by default, but give the reader the option to show it:
In [1]:
#collapse-hide
import pandas as pd
import altair as alt
put a #collapse-show
flag at the top of any cell if you want to show that cell by default, but give the reader the option to hide it:
In [2]:
#collapse-show
cars = 'https://vega.github.io/vega-datasets/data/cars.json'
movies = 'https://vega.github.io/vega-datasets/data/movies.json'
sp500 = 'https://vega.github.io/vega-datasets/data/sp500.csv'
stocks = 'https://vega.github.io/vega-datasets/data/stocks.csv'
flights = 'https://vega.github.io/vega-datasets/data/flights-5k.json'
If you want to completely hide cells (not just collapse them), read these instructions.
In [3]:
# hide
df = pd.read_json(movies) # load movies data
df.columns = [x.replace(' ', '_') for x in df.columns.values]
genres = df['Major_Genre'].unique() # get unique field values
genres = list(filter(lambda d: d is not None, genres)) # filter out None values
genres.sort() # sort alphabetically
Interactive visualizations made with Altair remain interactive!
We leave this below cell unhidden so you can enjoy a preview of syntax highlighting in fastpages, which uses the Dracula theme.
In [4]:
# select a point for which to provide details-on-demand
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
alt.X('date:T'),
alt.Y('price:Q', scale=alt.Scale(type='log')),
alt.Color('symbol:N')
)
alt.layer(
base, # base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='date:T'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
text='price:Q'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='left', dx=5, dy=-5).encode(
text='price:Q'
).transform_filter(label),
data=stocks
).properties(
width=500,
height=400
)
Out[4]:
In [5]:
# display table with pandas
df[['Title', 'Worldwide_Gross',
'Production_Budget', 'IMDB_Rating']].head()
Out[5]:
Typing > twitter: https://twitter.com/jakevdp/status/1204765621767901185?s=20
will render this:
twitter: https://twitter.com/jakevdp/status/1204765621767901185?s=20
Typing > youtube: https://youtu.be/XfoYk_Z5AkI
will render this:
youtube: https://youtu.be/XfoYk_Z5AkI
Typing > Warning: There will be no second warning!
will render this:
Warning: There will be no second warning!
Typing > Important: Pay attention! It's important.
will render this:
Important: Pay attention! It's important.
Typing > Tip: This is my tip.
will render this:
Tip: This is my tip.
Typing > Note: Take note of this.
will render this:
Note: Take note of this.
Typing > Note: A doc link to [an example website: fast.ai](https://www.fast.ai/) should also work fine.
will render in the docs:
Note: A doc link to an example website: fast.ai should also work fine.
This tutorial contains more examples of what you can do with notebooks.
fastpages uses nbdev to power the conversion process of Jupyter Notebooks to blog posts. When you save a notebook into the /_notebooks
folder of your repository, GitHub Actions applies nbdev
against those notebooks automatically. The same process occurs when you save Word documents or markdown files into the _word
or _posts
directory, respectively.
We will discuss how GitHub Actions work in a follow up blog post.
We highly encourage you to start blogging with fastpages
! Some resources that may be helpful:
If you end up writing a blog post using fastpages, please let us know on Twitter: @jeremyphoward, @HamelHusain.