Search code examples
markdownharp

Is there a way to set css in harp when displaying markdown files?


Markdown without css is not very appealing to look at, and I would like to customize the visual display when viewing markdown files in harp. Is there any way to do this?


Solution

  • If you have a _layout.ejs or .jade file in your project, it can wrap all the Markdown you write.

    For example, in _layout.ejs you might have:

    <html>
      <head>
        <title>My Site</title>
        <script src="/css/main.css" rel="stylesheet"></script>
      </head>
      <body>
        <%- yield %>
      </body>
    </html>
    

    Now, any Markdown files you have will be rendered where <%- yield %> is, so you can style them in the main.css file I’ve referenced in the link tag there.

    Here is the full documentation for layout files

    I also go through this in more depth in an article about starting a blog with Harp. Hope it’s helpful!