tlienart / Franklin.jl

(yet another) static site generator. Simple, customisable, fast, maths with KaTeX, code evaluation, optional pre-rendering, in Julia.
https://franklinjl.org
MIT License
951 stars 113 forks source link

Tools/workflow tips for migrating to Franklin #829

Open logankilpatrick opened 3 years ago

logankilpatrick commented 3 years ago

Hey @tlienart are there any specific steps or the like that one would take to migrate from Jekyll (for example) to Franklin? I have some websites I want to help move over but don't want to start down the wrong path.

tlienart commented 3 years ago

I should probably add a note in the docs on how to do this. The rough steps are as follows:

  1. porting the design (adjusting the _layout and adding the correct javascript and css in _libs and_css)
  2. migrating the content (mostly copy pasting, possibly commenting out Jekyll specific front matter)
  3. adjusting page aggregation (e.g. "latest blog posts" or "tags") possibly via hfuns

Porting the design

This is usually what takes the most time depending on how complex the website is as CSS and HTML can often be a bit finicky.

Usually there's two layouts to port (one when you're lucky): (1) the landing page and (2) the blog post pages. The procedure is identical and the main idea is to identify the repeated design elements in those pages and put those in the relevant _layout/* files.

To begin with the cover page

That's basically it, same procedure for the posts page. If you want to load different blocks of layout for some pages, just use {{ispage /index.html}} ... {{end}} or {{isnotpage ...}} ... {{end}} etc.

One note: by default a Franklin page will look like this:

<!-- usual top stuff doctype etc, head -->
<body>
  <div class="franklin-content">
    <!-- here all the content transformed from the source markdown -->
    <!-- here whatever is in page_foot -->
  </div>
  <!-- here whatever is in foot -->
</body>
</html>

if you do not want the content to be wrapped in a div with class franklin-content (this would be the case for instance if you're using bootstrap), then you can disable this by putting the following in your config.md:

+++
content_tag = ""
+++

the content_tag = "" will disable the wrapping into a <div class="franklin-content"> and you can do this wrapping manually into whatever div you want or a <main> or whatever by putting that explicitly in your _layout/head

Migrating content

This is an easy step. Usually most of it can just be copy pasted. The only thing is that if there's Jekyll specific commands (e.g. front matter or whatever) used in those pages, it should be commented out for now and replaced by something Franklin-admissible later.

Aggregation

This will depend on the scenario. The most standard one is to have a list of either all blogposts in chronological order or the x-most recent blogposts, possibly paginated. The pagination can be handled by Franklin, so the main thing to consider is to generate a list and you could do this many ways, as long as it can easily be coded in Julia, you're fine. An example for this is the one used for the Julia website blog:

https://github.com/JuliaLang/www.julialang.org/blob/b2d961df95f9ec1ac981feac2677d3fa8538afcc/utils.jl#L48-L139


I hope this kind of makes sense, ping me from one of these repos when you have questions and I'll eventually put stuff together into a doc page

logankilpatrick commented 3 years ago

This helps a ton! Thank you.

logankilpatrick commented 3 years ago

This proved to be quite difficult. I tried to do this for https://github.com/FluxML/fluxml.github.io and ran into some issues with the navigation bar. The CSS does not seem to load. It looks like the CSS file from before was a SCSS file, would that matter?

tlienart commented 3 years ago

the SCSS can usually just be ignored. If you have a draft on a repo somewhere, add me as contributor and I'll have a look (ideally from specific issues I can try to address one by one async)