-
-
Notifications
You must be signed in to change notification settings - Fork 5
Setting up the Stanford Daily website on your Mac or Windows using Local by Flywheel
Now you can use Vagrant to set up the local server (which is way easier)!
Before you begin to contribute to the Stanford Daily website, you have to set up a local development environment so that you can test your code first before it is deployed on the actual Daily server. In another word, you will develop and debug using a cloned Stanford Daily website on your own computer. (Why do we need a local development environment?)
Local by Flywheel is a free local development environment for Mac and Windows designed to simplify the workflow of WordPress developers.
-
Download Local by Flywheel from its website https://local.getflywheel.com.
-
Install according to the instructions. (For Mac, just drag the app to
~/Applications/
folder) -
Launch the application. Initialize the app according to the instructions (just click Next should be okay).
-
Click the button “Create a new site.” You should be now on a page like this:
- Enter the site name and the local site domain (i.e., the URL of your local Daily site; in my screenshot, it is http://tsd.local/), and choose where your site file will be stored. Then click "Continue."
-
Here we will choose PHP version and web server software your local Daily site will use. Sticking to "Preferred" should be fine. Then click "Continue."
-
Now set your local Daily site's username, password, and email. Since only your computer will have access to the website itself (hence "local"), you can just enter anything you like. Then click "Add site."
-
Wait some time for the program to set up your website. Enter your computer password when prompted.
-
Now you should be back to the Dashboard. You can try clicking the "View Site" button to visit the site. You'll notice that currently, the site is not using the theme and plugins the Daily uses. As such, we still have to clone the Daily site before we can start coding.
- Click the little arrow next to your folder path in Local by Flywheel to open the directory. Go in
app/public
to see your actual website files. Delete the two folderswp-content/themes
andwp-content/plugins
.
- Open https://github.com/TheStanfordDaily/stanforddaily-website and click the "Clone or download" button. Use a method you preferred (if you are new to git, I recommend using GitHub Desktop) to clone to the site to your computer.
-
Open the cloned folder, copy the two folders
wp-content/themes
andwp-content/plugins
from the cloned website to your local website folder (the one you opened in step 1). -
Login to your local Daily site. Go to "Appearance" - "Themes" and activate the theme "JNews - Child Theme" (NOT the "
JNews" theme).
- Then go to "Plugins," select all plugins, change "Bulk Actions" to "Activate", and click "Apply" button.
-
You will notice that there are lots of messages showing right now. You can safely ignore all of them.
-
Now go to your local Daily site, and you should be able to see a somewhat similar website to the actual Daily website. Congratulations! You can now start working on your code and making the Stanford Daily website better than ever!
Sometimes you might want to see how the Daily website looks on your phones or tablets. To access your local website from other devices, click the "Enable" button next to "Live Link" at the bottom.
Now a link (like abcdefgh.ngrok.io
) will be shown. You can now visit your local website from other devices using this link. Remember to disable "Live Link" after you have finished testing.
Currently, the local site only has one test article. To mock the actual site and test your design with different content, you have several options:
-
Using WordPress plugins like FakerPress to generate dummy content.
-
Exporting articles and other content from the actual Daily site and importing them into your local site using WordPress's built-in "Import" and "Export" tools (under the "Tools" section in admin page).
-
[ADVANCE] Importing the actual Daily database into your local database.
-
For most, if not all, of the time, you only need to modify files inside the folder
wp-content/themes/jnews-child/
. You do not need to (and should not) modify any file inside the folderwp-content/themes/jnews/
. -
Before committing your changes, check carefully you are only committing the files you want to change.
-
Have fun! 😉
TODO...