Static Site Generator Plugin

anything else i can provide you with to solve this issue?

Thanks for posting your config. It looks alright, unfortunately I can not reproduce your issue, yet. I didnā€™t test on a Mac, but on Linux it works just fine together with the starterkit and your config + blueprint.
Just to be sure: This is how you run kirby with php-cli:

php -S localhost:8000 kirby/router.php

right? (If you use a different port that doesnā€™t matter, but the kirby/router.php part at the end is relevant.)

yes i do use the router.php but instsead of localhost iā€™m using my macs IP so that i can test the website on my iphone on the same network as well.

iā€™ll try using git and uploading it to a real server today. maybe the problem will silve itself thenā€¦

THANKS FOR YOUR HELP SO FAR! really impressed by this community!

Please let me know how it goes :slight_smile: Iā€™ve also tried to reproduce on a Mac (OS 10.15.4) without success. What we didnā€™t fully rule out is if youā€™re using other plugins etc. which might influence some behavior. Would be great if you could test if it works if you clone the latest starterkit, then clone the plugin into the plugins folder, adapt the config and blueprint as you posted and then try if it works (without any other plugins etc.)
Thanks and good luck!

ok so i found out was is causing your plugin to break within my kirby install. Its the ā€œkirby modulesā€ plugin by @thguenther. I couldnā€™t excactly figure out what part is causing the problems but when i delete it from my install the static html plugin works fine. Maybe you could install it in your testenvironment and take a look if you can find the issue? I canā€™t delete the modules plugin since its a key part of my installā€¦
thanks so much in advance for any kind of help!

@antonlinus Did you try updating to 3.4.0-rc.2? There was an issue with my modules plugin: https://github.com/medienbaecker/kirby-modules/issues/10#issuecomment-648894740

i tried using git checkout develop but that didnā€™t work, so i downloaded the attached source code from your link and replaced the contents of my kirby folder with the ones inside the source code zip. this seems to have worked since i now get version 3.4.0 rc2 displayed when login on to the panel site. Yet when i throw the static site generator plugin into the plugins folder i now immediatly get this errormessage:

Error thrown with message "Using $this when not in object context"

Stacktrace:
#8 Error in /Users/antonlinus/Library/Mobile Documents/com~apple~CloudDocs/Documents/Git/odds_without_ends_kirby/www/kirby/src/Cms/App.php:363
#7 Kirby\Cms\App:component in /Users/antonlinus/Library/Mobile Documents/com~apple~CloudDocs/Documents/Git/odds_without_ends_kirby/www/site/plugins/kirby-static-site-generator/media.class.php:7
#6 require_once in /Users/antonlinus/Library/Mobile Documents/com~apple~CloudDocs/Documents/Git/odds_without_ends_kirby/www/site/plugins/kirby-static-site-generator/index.php:7
#5 include_once in /Users/antonlinus/Library/Mobile Documents/com~apple~CloudDocs/Documents/Git/odds_without_ends_kirby/www/kirby/src/Toolkit/F.php:415
#4 Kirby\Toolkit\F:loadOnce in /Users/antonlinus/Library/Mobile Documents/com~apple~CloudDocs/Documents/Git/odds_without_ends_kirby/www/kirby/src/Cms/AppPlugins.php:798
#3 Kirby\Cms\App:pluginsLoader in /Users/antonlinus/Library/Mobile Documents/com~apple~CloudDocs/Documents/Git/odds_without_ends_kirby/www/kirby/src/Cms/AppPlugins.php:769
#2 Kirby\Cms\App:plugins in /Users/antonlinus/Library/Mobile Documents/com~apple~CloudDocs/Documents/Git/odds_without_ends_kirby/www/kirby/src/Cms/AppPlugins.php:601
#1 Kirby\Cms\App:extensionsFromPlugins in /Users/antonlinus/Library/Mobile Documents/com~apple~CloudDocs/Documents/Git/odds_without_ends_kirby/www/kirby/src/Cms/App.php:129
#0 Kirby\Cms\App:__construct in /Users/antonlinus/Library/Mobile Documents/com~apple~CloudDocs/Documents/Git/odds_without_ends_kirby/www/index.php:5

heres a screenshot as well:

@antonlinus thank you, that makes sense. Can you try if this fix works for you?


(branch bugfix/media-original-fns)

The command to clone directly to the branch and name the folder static-site-generator is:

git clone -b bugfix/media-original-fns https://github.com/d4l-data4life/kirby3-static-site-generator.git static-site-generator

Thanks!

1 Like

thanks @jonathan-reisdorf & @thguenther i installed your fix but now i canā€™t seem to log into panel anymore haha. it just shows a blank page. website is working fine but panel is not accesible anymore. i also installed your fix on a 3.3 kirby install and it threw an call on member function (null) error or something but it did create a static folder and an html file.

ok looks like your fix might work for the 3.3 install. this call on member function (null) error might be on my endā€¦ iā€™ll keep you guys posted. thanks a lot

@jonathan-reisdorf Thank you fo this great plugin. I am trying it out and everything seems to work fine except one thing. I am using strftime as documented here so I can translate month names in a multilingual setup. Static version does not seem to respect the locale and returns names in English. Any ideas?

Hello,
this plugin serves us very well, but Iā€™m wondering about the .kirbystatic file, that is created in the output folder. Why is it created? Is it necessary for the website to work?
It doesnā€™t seem so, but just wanted to make sure.
Kind regards,
Alex

Hi Alex,
the plugin has a built-in check to make sure that the specified output folder either does not exist, is empty or contains a previously built static website before the generation starts. The reason for that is that all files in the output folder (except the protected ones) are erased before the build and in order to avoid accidental deletion of files this safety check is in place. The empty .kirbystatic file is created when generating the static site for the first time and from that moment on acts as a flag to tell the generator that itā€™s safe to overwrite the contents of this folder. Of course e.g. when uploading the files to a CDN you can safely skip this one, it serves no function other than for the kirby plugin.
Best regards,
Jonathan

Hi @phrase,
sorry for the late response. :see_no_evil: Does your problem still exist? I have a working setup with strftime in a statically generated multilanguage site, and canā€™t reproduce it there. I just had some initial troubles setting up the locales in the system if I remember correctly.
Iā€™m happy to research this issue further if it still exists! Thanks and best regards!

Hey @jonathan-reisdorf, thanks for creating the plugin.

I am trying to get it up and running but have had no luck thus far. I made the following changes

Downloaded the content of the plugin and placed it in site/plugins. it comes up on UI (/system), so assuming it was installed correctly.

site/config/config.php

<?php

return [
    'debug'  => true,
    'd4l' => [
      'static_site_generator' => [
        'endpoint' => 'generate-static-site', # set to any string like 'generate-static-site' to use the built-in endpoint (necessary when using the blueprint field)
        'output_folder' => './static', 
      ],
    ],
];

site/blueprint/site.yml

title: Site
fields:
  staticSiteGenerator:
    label: Generate a static version of the site

This to me seems all I had to do to get the basics set up. However, I am faced with the following error on the panel:

Field "staticsitegenerator": The field type "staticSiteGenerator" does not exist

Additional Info:
Kirby - v3.9.7
PHP - 8.2
OS - macOS

Any and all help is appreciated, thanks in advance.

Hey @dhrumil,

thank you for reporting. Are you using the PHP built-in server, but did not specify the router file? This would be a common reason for the error showing up. In that case, try running e.g. php -S localhost:8765 kirby/router.php

Hey @jonathan-reisdorf, yes I was using the built-in server without specifying the router file. It works now, thanks for the help, I appreciate it.