Giter Site home page Giter Site logo

odm-site-initiative's Introduction

How to build this site

This site is made with MkDocs and in particular with its extension Material for MkDocs.

Both are great tools that build a static site starting from simple markdown documentation.

They provide many amazing features, perfectly documented in their websites, with step-by-step tutorials to create a new site from scratch.

However, we would like to explain here all the prerequisites needed to build this very site and an overview of the principal customizations implemented.

Setup

The first thing to do in order to be able to build this site is to install Material for MkDocs, it will also install all dependencies: MkDocs, Markdown, Pygments and Python Markdown Extensions:

pip install mkdocs-material

In order to add the date of the last update and creation of a document at the bottom of each page, we enabled the git-revision-date-localized plugin, which can be installed with pip:

pip install mkdocs-git-revision-date-localized-plugin

Finally, two Python libraries must be installed to generate the social preview images, both of which are based on Cairo Graphics โ€“ Pillow and CairoSVG.

Install pillow and cairosvg with pip:

pip install pillow cairosvg

Install the other dependencies depending on your system:

Linux

There are several package managers for Linux with varying availability per distribution.

Ubuntu

apt-get install libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev

If you are on Ubuntu you can directly launch the setup.sh script located in script folder! It contains all the previously described steps.

Fedora

yum install cairo-devel freetype-devel libffi-devel libjpeg-devel libpng-devel zlib-devel

openSUSE

zypper install cairo-devel freetype-devel libffi-devel libjpeg-devel libpng-devel zlib-devel

Windows

The easiest way to get up and running with the Cairo Graphics library on Windows is by installing GTK+ since it has Cairo as a dependency. You can also download and install a precompiled GTK runtime.

macOS

Make sure Homebrew is installed, which is a modern package manager for macOS. Next, use the following command to install all necessary dependencies.

brew install cairo freetype libffi libjpeg libpng zlib

Building

In order to build the site, the following command must be launched in the root directory:

mkdocs build

It is not necessary to explicitly build the site before serving or publishing but it can be useful to inspect the site folder it creates to verify resource paths.

It is also useful for sites published without the aid of GitHub Pages since the site folder is the deployment unit.

Serving

In order to locally test the site it is possible to launch the following command in the root directory:

mkdocs serve

The site will be hosted at the address configured in mkdcos.yml and almost any change in the docs folder will trigger an automatic republish.

Publishing

If the site is published through GitHub Pages, as it is in our case, it can be easily deployed with a single command:

mkdocs gh-deploy --force

The site will soon appear at '<username>.github.io/<repository>'.

If you wish to publish the site using GitHub pages but on a custom domain, this guide contains all the available possibilities.

If you don't want to use GitHub pages, you can always build your site as explained before and upload the content of the site folder to your hosting provider.

Notable Configurations and Customizations

mkdocs.yml

Most of the configurations reside in the mkdcos.yml file, located in the root folder.

The site_* and repo properties configure website and repository locations and meta tags for the website.

The nav section defines the structure of the site and the location of each markdown document published.

The theme, markdown_extensions and plugins sections contain all the Material for MkDocs configurations currently used and the extensions required to make them work.

The analytics and consent sections configure the usage of Google Analytics and govern cookie consent.

The social and copyright sections define the content of the footer, copyright and social icons.

extra.css

The few CSS customizations we use can be found in docs>stylesheets>extra.css.

It contains the color palette we picked and a slight increase in the width of the pages.

home.html

The homepage is written directly in HTML since we wanted it to be different from the rest of the site.

It can be found in docs>override and has its own customized style embedded.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.