This is a small business template built with Victor Hugo, Auth0, and Netlify CMS, designed and developed by Darin Dimitroff, spacefarm.digital.
Create a free Auth0 account if you don't have one already. Follow all of the onboarding instructions, including creating a new application in whatever region you like.
Go to the "Clients" tab of the Auth0 dashboard and create a new client for a single page application.
Go to the Client tab and click on the connection you created previously. It should look like this:
Use our deploy button to get your own copy of the repository:
Add Auth0 Domain and Client ID in the Netlify Deploy Wizard, both can be retrieved from the create Auth0 account.
Go back to the Users tab of your Auth0 dashboard and click on a user you created previously. Scroll down to the Metadata section.
You can setup a rule to make sure every created user will be assigned the role user
.
function (user, context, callback) {
user.app_metadata = user.app_metadata || {};
// You can add a Role based on what you want
// In this case I check domain
var addRolesToUser = function(user, cb) {
if (user.email && user.email.indexOf('@example.com') > -1) {
cb(null, ['admin']);
} else {
cb(null, ['user']);
}
};
addRolesToUser(user, function(err, roles) {
if (err) {
callback(err);
} else {
user.app_metadata.authorization.roles = roles;
auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
.then(function(){
callback(null, user, context);
})
.catch(function(err){
callback(err);
});
}
});
}
Once the authentication is don is done, you can to setup the GitHub integration for Netlify CMS.
Go to https://github.com/settings/developers and register a new application.
Then go to the "Access" tab in your new Netlify site and add a GitHub authentication provider.
Once that's done, you'll be able to enter the CMS by going to the URL of your new site and appending /admin
Clone this repository, and run yarn
or npm install
from the new folder to install all required dependencies.
Then start the development server with yarn start
or npm start
.
The template is based on small, content-agnostic partials that can be mixed and matched. The pre-built pages showcase just a few of the possible combinations. Refer to the site/layouts/partials
folder for all available partials.
Use Hugo’s dict
functionality to feed content into partials and avoid repeating yourself and creating discrepancies.
The template uses a custom fork of Tachyons and PostCSS with cssnext and cssnano. To customize the template for your brand, refer to src/css/imports/_variables.css
where most of the important global variables like colors and spacing are stored.
All SVG icons stored in site/static/img/icons
are automatically optimized with SVGO (gulp-svgmin) and concatenated into a single SVG sprite stored as a a partial called svg.html
. Make sure you use consistent icons in terms of viewport and art direction for optimal results. Refer to an SVG via the <use>
tag like so:
<svg width="16px" height="16px" class="db">
<use xlink:href="#SVG-ID"></use>
</svg>