Syncing Your Subtheme
Since you have now created a custom subtheme, you will want to add it to the website on SiteFactory. To do this we need to commit your code, push it up to a code repository, and sync that repository to your site in SiteFactory.
Commit Your Code
We mentioned above that we assume you have Git installed. You can double check that you have Git installed by running git -v
. If you get a version number you have it installed. If not the easiest way to install it is to download and install X Code from the App Store. If you use a package manager for your Mac like Homebrew you can also easily install it with this Formulae.
Navigate to the root of your subtheme, in our example that is:
cd ~/websites/mywebsite/docroot/sites/default/themes/my_custom_subtheme
Now initiate a Git project by running git init
.
You should see a message, Initialized empty Git repository in {path to directory}
.
Now type git status
and you should see all your files in red. These are your untracked files. To track them, you will need to add them to a list of files to be committed by typing git add .
, this will add all these files to the list changes to be committed. If you run git status
again, these files will now be in green under a title of "Changes to be committed".
To commit them type git commit -m "Initial commit"
. In the quotes you will always write a message describing the changes you made to the code.
Now if you run an additional git status
you will get a message, "On branch main nothing to commit, working tree clean".
This means our code is now part of the git managed code and thus ready to push up to a repository.
Set Up A Remote Repo
Now in your preferred code repository (GitHub, BitBucket, etc.) create a new repo and name it after the subtheme. Preferably you will make this a private repository, if you do you will need to generate SSH keys on your local machine and add them to your online account with your preferred code repo. Making this public may not be the end of the world, it just means that anyone has access to see your code, so if for some reason the code you write exposes a vulnerability it can be used to exploit your site.
Here is an example of setting this up in BitBucket.
By not including a README or .gitignore
file you will be prompted to push some code.
Push Code to The Remote Repo
Do steps 1 and 2.
Open a terminal window and navigate into the root of your subtheme.
Then add a remote to your Git setup by typing git remote add origin git@bitbucket.org:ietwebdev/my-custom-subtheme.git
Then verify that you now have a remote by typing git remote -v
. You should see a push and pull address for a remote called "origin".
Now push your code to the remote repo using git push -u origin main
. Origin is the name of the remote location, and main it the name of your branch that you have added your code to.
If you go to your repo online, you should now see all your code.