WordPress: Difference between revisions
imported>Onny Add notes on SEO |
imported>Onny mNo edit summary |
||
| Line 160: | Line 160: | ||
'''Picture compression''' | '''Picture compression''' | ||
Your website gets better ranking for search engines if it is optimized to load fast. The Wordpress plugin [https://wordpress.org/plugins/webp-express webp-express] compresses your existing and future images automatically into a modern efficient image format and reduces their file size. | |||
Following example installs the plugin and adds an additional writeable directory to the Wordpress package, otherwise the plugin will fail due to permission issues. This hack only works for one specific instance, in this example for ''example.org''. Replace the site name on all occurrences. | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
services.wordpress.sites."example.org" = { | services.wordpress.sites."example.org" = { | ||
plugins = [ pkgs.wordpressPackages.plugins.webp-express ]; | plugins = [ pkgs.wordpressPackages.plugins.webp-express ]; | ||
}; | }; | ||
nixpkgs.overlays = [ | |||
(self: super: { | |||
wordpress = super.wordpress.overrideAttrs (oldAttrs: rec { | |||
installPhase = oldAttrs.installPhase + '' | |||
ln -s /var/lib/wordpress/example.org/webp-express $out/share/wordpress/wp-content/webp-express | |||
''; | |||
}); | |||
}) | |||
]; | |||
systemd.tmpfiles.rules = [ | |||
"d '/var/lib/wordpress/example.org/webp-express' 0750 wordpress wwwrun - -" | |||
]; | |||
</syntaxHighlight> | </syntaxHighlight> | ||
In the Wordpress administrator interface go to ''Settings -> WebP Express''. One possible configuration which is suitable for the NixOS module could be | |||
* Scope: Uploads only (we cannot convert theme files) | |||
* Destination folder: Mingled (save webp converted images in the same place as original files) | |||
* File extension: Set to ".webp" | |||
* Destination structure: Image roots | |||
* Disable all .htaccess rules (doesn't apply for any web server) | |||
* Convert on upload: yes (future uploads will be converted to webp file format) | |||
* Alter HTML: Replace image URLs (we'll only reference compressed webp images on the page) | |||
* Reference webps that haven't been converted yet: Yes | |||
* How to replace: The complete page | |||
Further click on ''Bulk convert'' to convert all existing images. | |||
'''Lazy load images''' | '''Lazy load images''' | ||