I've been playing around with supporting 'Dark Mode' in this site ever since it was introduced in macOS. If nothing else, it's a fantastic way to showcase photos. With its introduction on iOS last year, I finally bit the bullet and added full support.

Debugging Dark Mode can be troublesome though, as testing often necessitates toggling it on and off to check a design in both modes; something macOS (unlike iOS) doesn't provide a convenience for.

Fortunately, iDownloadBlog.com has a fantastic article describing how to use Automator to add a button to the MacBook Pro's Touch Bar that executes the following AppleScript:

tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell

Their approach adds a Service to the Services Menu, and then describes how to get this to show up on the Touch Bar. It doesn't--in my opinion--go quite far enough though, as they don't add a global keyboard shortcut for moments when the Touch Bar is unavailable. You can do this by selecting 'Services' in the 'Keyboard' section of 'System Preferences', finding your new service, and recording the key combination you'd like to use:

System Preferences → Keyboard → Shortcuts

Check out the original article for full instructions.