- Each Wowchemy shortcode consists of an HTML file
- You may use Go Templating, shortcode parameters, and Bootstrap layouts to design the shortcode
- Click the Use This Template button on GitHub
- Name your repository
wowchemy-shortcode-<SHORTCODE-NAME>where<SHORTCODE-NAME>is an appropriate name for your shortcode
- Name your repository
- Browse your new GitHub project, click the
go.modfile, and then the ✏️ pencil button to edit it- Replace the placeholder URL in
go.modwith your new GitHub URL in the formmodule github.com/<USERNAME>/wowchemy-shortcode-<SHORTCODE-NAME>where<USERNAME>is your GitHub username and<SHORTCODE-NAME>is the name of the shortcode - Scroll to the bottom and click Commit Changes to save
- Replace the placeholder URL in
- Browse to the
layouts/shortcodes/folder, clickmy-shortcode.html, and click the ✏️ pencil button to edit it- Rename
my-shortcode.htmlin the text box to a unique ID in the formgithub_<USERNAME>_<SHORTCODE-NAME>.html, again replacing<USERNAME>with your GitHub username and<SHORTCODE-NAME>with your shortcode name - Scroll to the bottom and click Commit Changes to save
- Rename
- Edit the HTML for your new shortcode
- You may use Go Templating and Bootstrap layouts
- View the Hugo docs on Shortcodes
- You can access the shortcode content using
{{.Inner}} - Check out the built-in shortcodes for inspiration
Say your GitHub username is pikachu and you wish to create a shortcode named pokemon:
- We click Use This Template and enter
wowchemy-shortcode-pokemonas the project name - We replace the first line of
go.modwithmodule github.com/pikachu/wowchemy-shortcode-pokemon - We browse to the
layouts/shortcodes/folder, and renamemy-shortcode.htmltogithub_pikachu_pokemon.html - We customize the HTML in
github_pikachu_pokemon.html - We add the shortcode to our site and share the shortcode with the community following the guide below
- Install your shortcode in your site by referencing it at the bottom of your
config/_defaults/config.toml:# At the bottom of your `config.toml` is a Module section: [module] # Your existing modules will appear here. # Add your shortcode's GitHub URL below. # Replace <USERNAME> and <SHORTCODE-NAME> with your GitHub username and shortcode name, respectively. [[module.imports]] path = "github.com/<USERNAME>/wowchemy-shortcode-<SHORTCODE-NAME>"
- Use your shortcode in page content. For example let's create
content/post/test-my-shortcode.md:--- title: My shortcode date: '2020-11-27' --- Check out my shortcode: {{% github_pikachu_pokemon %}}Content to *process*.{{% /github_pikachu_pokemon %}}