Once you have your blog set up and deployed to a host like Netlify, it’s entirely possible to write, edit, and publish new blog posts without needing to touch the Git repository.
Still, you might want to share a link with someone else for proofreading or review. (Or, maybe you just want to take a quick peek at how your draft is coming along before pressing Publish.)
With a few additional configurations, you can create a simple admin-like setup for managing your content:
- Show unpublished drafts
- Display “Edit this post on Portway” links on individual blog posts
- Expose a Build button to trigger manual builds — Coming soon!
Example — To get an idea of what this looks like in practice, take a peek at the “secret” admin deployment for this site.
Admin deployment
Creating a second “admin” deployment on Netlify allows you to enable admin tools in an environment that’s identical to your actual site!
- In the Netlify dashboard, click the New site from Git button
- Select your Git provider
- Find and select the Git repo for your blog created during initial setup
Once you’ve created a second deployment, use the environment variables described below to enable admin features. Heads up! — Unless you don’t mind random people stopping by to read your drafts, your admin deployment should use a secret, unguessable URL 🤫
Enabling admin features
A few admin features are controlled by special environment variables.
In Netlify, these can be found and managed under Site Settings → Build & deploy → Environment.
Tip — After adding, removing, or updating configuration environment variables, be sure to rebuild your site for the changes to be reflected
Show Drafts
To show unpublished posts on your admin deployment, add an environment variable PORTWAY_SHOW_DRAFTS
with a value of true
.
Note — Take care not to enable this on your production site, or blog posts may appear before they have been published.
To change this behavior on your local machine, add the following line to your .env
file:
PORTWAY_SHOW_DRAFTS=true
Show “Edit in Portway” links
As a convenience, you can configure your admin site to show “Edit this post in Portway” links at the bottom of each blog post like this:
To enable this feature, add the environment variable PORTWAY_SHOW_EDIT_LINK
with a value of true
:
To change this behavior on your local machine, add the following to your .env
file:
PORTWAY_SHOW_EDIT_LINK=true
Show “Build” button
Coming soon!
Previewing draft updates
Since automatic deployment via webhook only happens when you click Publish in Portway, incremental edits to a document won’t automatically be reflected on your admin site.
In general this is desirable, since you probably don’t want to trigger a build each time you make a minor change. But it means we have to take an extra step to manually build your admin site to reflect your latest edits.
Deploying manually from Netlify
To kick off a build of your site to display the latest changes:
- Open the Sites tab in the Netlify dashboard
- Click or tap your admin deployment
- Open the Deploys tab
- Click or tap the Trigger deploy button
- Select Deploy site
Click “Build”
Coming soon!