I have an existing brochure/portfolio type website, written in php, (no backend database) that I would like to transition to static html. The site has over 100 pages. What would be the best way to do this? Should I recreate the entire website on a dev server, then run the build process and deploy the new html site (contents from _site folder) all at once? Or, is there a way to build just a few pages at a time and deploy them, replacing the existing php pages of the current site?
By default, Jekyll simply copies most files from the source to
_site, so one approach would be start with the whole PHP site as Jekyll source. At first, Jekyll would build an exact duplicate of the existing site in
_site, PHP and all. Next you could start replacing individual pages (e.g. replace
/about/index.md, etc) to replace the PHP.
Thanks Chuck for the advice. I was thinking that I would start out that way but I didn’t want to waste the time and effort if it wasn’t going to work. Only problem I might run into is the pages that have some inlined php script. I’ll give it a try. Thank you!
Indeed that’s what I found one of the coolest things with Jekyll: Just use the full old html product as source for Jekyll. Then Jekyll will simply reproduce it for you. After that, slowly replace each former html with a eponymous markdown (md) file, inserting front matter after having written your default layout. Page by page, everything becoming more standardised (relying on central layouts and some includes); took more than a year for me, all the time seemingly running as before. And all content is now written in md.
It is not clear what you want to do. This line says PHP to static HTML (which i read as no Jekyll)
And the subject says transition PHP to Jekyll.
If you want the first approach, yes you can use your build output to be served on GitHub Pages or whatever without Jekyll used.
And you can do it one page at a time. But you’d have to be careful. Your PHP files likely depend on each other and so a PHP file loading another PHP file which is now HTML is gonna break.
Also your site will be a nightmare to maintain. If you want to add an item in a navbar say, you’ll have to edit 100 pages to add one line and will also have to make a manual change for the selected page to know it’s the current page.
If you want to go PHP to Jekyll with no static site phase in between, I’d say create a new repo which starts off as a basic Jekyll site. Get your Gemfile, config, and maybe default layout and page layout set up and one or two pages. Then start moving your content across into markdown pages.
Because of layouts, you only need to add the content bit of a page, ie the body that is unique to a page and leave out the navbar which is handled by a layout. You might have to rewrite your PHP and HTML as markdown.
What you can also do is a hybrid approach. Get your Jekyll site set up as above so you have your homepage built in markdown and looking identical to your old homepage.
Then you can take the HTML build output from the old site and copy it into the content part of each new markdown page. Note that HTML works fine in markdown, just watch your indentation. Or keep the extension as about.html etc. That way you can migrate your site content quickly using copy and paste for each page, yet still have say the navbar and logo and footer handled by Jekyll.
What you say about inline PHP scripts - I guess you can start with copy and pasted HTML and then come back to replace those with Liquid equivalent that references a variable in config or a data file.
The advantage of copying the HTML across means you are living in a new Jekyll site quickly and don’t have to maintain two sites for a few months. The downside is any changes in the Jekyll site are slower while in plain HTML rather than markdown and Liquid which will take time to figure out