Code Monkey home page Code Monkey logo

website-build's Introduction

My website's build pipeline

This is a simple Gulp pipeline to convert particularly organized Markdown content to static html. This is a quick personal project which I just put up here so others might benefit. It is not supported.

You can find my website at pnksmr.fr.

Getting started

  • Install Gulp if you haven't already done so
  • Run npm update && npm install
  • Add a /src folder with template and content folders
    For an example see my website's content repo
    • The /src/template should contain:
      • index.html, your default template
      • images/ for any images
      • scss/styles.scss for your styles
    • Put you site content in /src/content
      • /src/content will be the root of your site in /pages
      • All files starting with % are ignored, so you can use that for files which you want to include without generating a separate html file for them
      • Any .md or .markdown files will be converted to html and wrapped in src/layout.html
      • Any other files will be copied as is
  • Run gulp build and watch /pages appear with your new website

I advice you to fork this project if you really want to use it, because changes might break your site at any time.

Using the template

I opted for a default template name of layout.html and the Handlebars template engine. The contents of the page will be present in the contents variable.

I also use FrontMatter to be able to add or modify template variables. This means you can make exceptions for the used template or engine by providing the layout (relative to the template directory) and engine variables. I also use the title variable to set the page title, and print a warning if it has not been set.

A very basic layout.html to use (using Handlebars):

<html>
  <head>
    <title>{{title}}</title>
  </head>
  <body>
    {{{contents}}}
  </body>
</html>

Using that with the following Markdown file:

---
layout: layout.html
engine: handlebars
title: Hello world
---
# Hello

Would deliver the following html:

<html>
  <head>
    <title>Hello world</title>
  </head>
  <body>
    <h1>Hello</h1>
  </body>
</html>

You can of course use more variables besides title to further modify your template.

Including files

Thanks to gulp-file-include you can include files using @@include("./%include.md") anywhere in the file. Files prefixed with % are not processed on their own and do not show up in ./pages by themselves.

Notes on markup

  • For my use, I wrap the content in an <article> tag. Any <p> in there with only images in it will get an images class which is useful for the style I am using. If you do not want this remove the appropriate from the content_markdown task.
  • A (rudimentary and inelegantly implemented) way to add footnotes is available. The idea is borrowed from MultiMarkDown. You can add a footnote as follows:
Here is some text containing a footnote.[^samplefootnote]

[^samplefootnote]: Here is the text of the footnote itself.

The reference will link to the footnote and the footnote will link back to the reference.

Projects used

License

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

website-build's People

Contributors

h-five-e avatar

Watchers

 avatar  avatar

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.