A WordPress Theme for the 2019 version of wearelighthouse.com
-
Make a new folder to contain everything, and change directory into it.
mkdir lighthouse && cd lighthouse
-
Download and extract the latest version of WordPress.
curl -o wordpress.zip https://wordpress.org/latest.zip && unzip -q wordpress.zip && rm -r wordpress.zip && cp -r wordpress/. . && rm -r wordpress
-
Clone this repo into the themes directory.
cd wp-content/themes/ && git clone https://github.com/wearelighthouse/Lighthouse-WordPress-Theme.git lighthouse && cd lighthouse
-
Fetch the fonts (password is in the Lighthouse 1Pass)
./assets/font/fetch.sh
-
Create your own .env from .env.example - then if not using defaults, edit it to change the database details.
cp .env.example .env
-
Install PHP dependencies.
composer install
-
Install NPM dependencies.
npm i
-
Start the docker container.
make up
-
Get browserSync running and watching for local file changes.
npm run watch
make up
- Start up the docker container, so that WordPress is accessible on localhost.
make down
- Stop the docker container - it's recommended that this is done before switching to any other projects.
make bash
- Open up a CLI inside teh docker container - usful for debugging or checking that the correct dependencies are installed.
See Makefile for more.
npm run build
- Build production version of css, fonts, images, JavaScript, etc. into /dist
.
npm run watch
- Run local hot-reloading server on localhost:3000. This also builds resources into
/dist`, but without minification.
See package.json and gulpfile.js for more.
To do both start-up commands at once, you can make up && npm run watch
. It's helpful to have an alias like makerun
for that.
Both npm run build
and npm run watch
remove the /dist
directory before re-creating it. It is also not a commited directory, so do not put important files in there manually. You can manually remove it with rm -r dist/
.
-
Go through the local WordPress installation. The
host
for your database is probablydb
notlocalhost
. -
Select the Lighthouse WordPress Theme in Appearance -> Themes.
-
To match the neat URLs on the live site, go to Settings -> Permalinks, then select 'Custom Structure', and paste in
/blog/%postname%/
. -
We use the standard WordPress export/importer for copying over site data (Tools -> Export/Import). As the database is so large, it can struggle with images, so we either have to play around with
wp-config.php
(related issue), or just add in aimages where they're needed to test with for local development. -
We set static pages for the Homepage and the Posts page. To do that, if site data has been imported so the pages already exist, go to Settings -> Reading, and choose
Home
andBlog
. -
The header navigation at the top of the site should be pulled through by the export/import, however it might not be selected to actually display in the right position. To check that, go to Appearance -> Settings, then check the 'Header Menu' Display location.
-
Footer info and Contact Details are not pulled over with the export/import. The best way to do that right now is just to copy/paste the contents fo the metaboxes from the live site (related issue).
-
For local development,
WP_DEBUG
should be changed fromfalse
totrue
insidewp-config.php
(which sits at the top level of the WordPress installation folder structure)define( 'WP_DEBUG', true );
We're using Cookie Consent for the cookie banner that pops up when you visit the site. It's settings and some inline style overrides are in cookie-consent.php - those are kept separate from our other JavaScript and CSS, so that they can be modified without having to run local build tools.
Some scripts and their cookies, for example Google Tag Manager, are never loaded when you're logged into the CMS, and/or when running the site locally. So to test accepting/rejecting of cookies, it's easiest to open up the live site in a private or icognito window.
Because we're loading a static version from a CDN, dependabot will not notify us of updates to the library. To upgrade, the version numbers in the stylesheet <link>
in header.php, and in the JavaScript <script>
in cookie-consent.php would need to be updated.