{"id":20261360,"url":"https://github.com/parsiya/hugo-shortcodes","last_synced_at":"2025-10-09T03:33:28.919Z","repository":{"id":63421421,"uuid":"54855958","full_name":"parsiya/Hugo-Shortcodes","owner":"parsiya","description":"Parsia's Hugo Shortcodes","archived":false,"fork":false,"pushed_at":"2022-11-02T16:36:21.000Z","size":160,"stargazers_count":109,"open_issues_count":7,"forks_count":14,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-11T01:47:14.820Z","etag":null,"topics":["hugo","shortcode"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parsiya.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-28T01:09:07.000Z","updated_at":"2025-02-20T05:38:58.000Z","dependencies_parsed_at":"2022-11-18T16:15:32.495Z","dependency_job_id":null,"html_url":"https://github.com/parsiya/Hugo-Shortcodes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/parsiya/Hugo-Shortcodes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parsiya%2FHugo-Shortcodes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parsiya%2FHugo-Shortcodes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parsiya%2FHugo-Shortcodes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parsiya%2FHugo-Shortcodes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parsiya","download_url":"https://codeload.github.com/parsiya/Hugo-Shortcodes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parsiya%2FHugo-Shortcodes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000714,"owners_count":26082911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hugo","shortcode"],"created_at":"2024-11-14T11:25:24.279Z","updated_at":"2025-10-09T03:33:28.904Z","avatar_url":"https://github.com/parsiya.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"## My Hugo Shortcodes\n\nThese are shortcodes that I have created for the [Hugo](https://gohugo.io)\nstatic blogging engine.\n\nTo use them, copy the HTML files into `your-hugo-blog/layouts/shortcodes/` or\n`your-hugo-blog/themes/current-theme/layouts/shortcodes/`. I do not suggest the\nsecond approach. Create the `shortcodes` directory if it does not exist. You can\nlearn more about shortcodes from\n[Hugo documentation](https://gohugo.io/extras/shortcodes/).\n\n- [My Hugo Shortcodes](#my-hugo-shortcodes)\n  - [Codecaption (codecaption.html)](#codecaption-codecaptionhtml)\n  - [Image Caption (imgcap.html)](#image-caption-imgcaphtml)\n  - [Wikipedia Link Generator (wp.html)](#wikipedia-link-generator-wphtml)\n  - [Octopress blockquote (blockquote.html)](#octopress-blockquote-blockquotehtml)\n  - [Year (year.html)](#year-yearhtml)\n  - [abbr HTML Tag (abbr.html)](#abbr-html-tag-abbrhtml)\n  - [mark HTML Tag (mark.html)](#mark-html-tag-markhtml)\n  - [Table of Contents (toc.html)](#table-of-contents-tochtml)\n  - [xref (xref.html)](#xref-xrefhtml)\n    - [Path](#path)\n    - [Anchor](#anchor)\n    - [Text](#text)\n    - [Title](#title)\n- [Editor Snippets](#editor-snippets)\n  - [Sublime Text Completions](#sublime-text-completions)\n  - [VS Code Snippets](#vs-code-snippets)\n  - [Atom Snippets - Archived](#atom-snippets---archived)\n- [License](#license)\n\n### Codecaption (codecaption.html)\nAdds title to code blocks.\n\n**Usage:**\n\n``` html\n{{\u003c codecaption lang=\"html\" title=\"Code caption shortcode\" \u003e}}\n\u003cfigure class=\"code\"\u003e\n  \u003cfigcaption\u003e\n    \u003cspan\u003e{{ .Get \"title\" }}\u003c/span\u003e\n  \u003c/figcaption\u003e\n  \u003cdiv class=\"codewrapper\"\u003e\n    {{ highlight .Inner (.Get \"lang\") \"linenos=true\" }}\n  \u003c/div\u003e\n\u003c/figure\u003e\n{{\u003c /codecaption \u003e}}\n```\n\nResults in:\n\n![Captioned codeblock](/images/codecaption1.png)\n\n### Image Caption (imgcap.html)\nThis shortcode adds captions to pictures. Due to the way the original css file\nwas organized, this shortcode does not use `\u003cfigure\u003e` and `\u003cfigcaption\u003e`. `Alt`\nwill also be set to title.\n\n**Usage:**\n\n    {{\u003c imgcap title=\"Sample caption\" src=\"/images/2016/thetheme/1.png\" \u003e}}\n\nResults in HTML:\n\n``` html\n\u003cspan class=\"caption-wrapper\"\u003e\n  \u003cimg class=\"caption\" src=\"/images/2016/thetheme/1.png\" title=\"Sample caption\" alt=\"Sample caption\"\u003e\n  \u003cspan class=\"caption-text\"\u003eSample caption\u003c/span\u003e\n\u003c/span\u003e\n```\n\n### Wikipedia Link Generator (wp.html)\nI attempted to the re-create the Jekyll Wikipedia link generator by\n[Keltia](https://github.com/keltia). You can see the source\n[here](https://github.com/keltia/octopress/commit/17b975067ff86c0c7cddac4ae2c2c975b0790b6e).\n\nYou can see the discussion on Hugo forums\n[here](https://discuss.gohugo.io/t/equivalent-to-jekyll-octopress-theme-named-cleanpress/2953)\nwith my original [gist](https://gist.github.com/parsiya/562f5d2bde3e9060d793).\n\nIt has some shortcomings. There are definitely better ways to do this.\nPersonally I prefer the named parameter version because the shortcode is easier\nto write but this should work for both.\n\n**Usage:**\n\nYou can either use named parameters:\n\n* {{\u003c wp tag=\"VIC_cipher\" \u003e}}\n* {{\u003c wp tag=\"VIC_cipher\" lang=\"fr\" \u003e}}\n* {{\u003c wp tag=\"VIC_cipher\" lang=\"fr\" title=\"\" \u003e}}\n* {{\u003c wp tag=\"VIC_cipher\" title=\"VIC Cipher\" \u003e}}\n* {{\u003c wp tag=\"VIC_cipher\" lang=\"en\" title=\"VIC Cipher\" \u003e}}\n\nRendered to:\n\n``` html\n\u003ca href=\"https://en.wikipedia.org/wiki/VIC_cipher\"\u003eVIC_cipher\u003c/a\u003e\n\u003ca href=\"https://fr.wikipedia.org/wiki/VIC_cipher\"\u003eVIC_cipher\u003c/a\u003e\n\u003ca href=\"https://fr.wikipedia.org/wiki/VIC_cipher\"\u003eVIC_cipher\u003c/a\u003e\n\u003ca href=\"https://en.wikipedia.org/wiki/VIC_cipher\"\u003eVIC Cipher\u003c/a\u003e\n\u003ca href=\"https://en.wikipedia.org/wiki/VIC_cipher\"\u003eVIC Cipher\u003c/a\u003e\n```\n\nOr positional:\n\n* {{\u003c wp VIC_cipher \u003e}}\n* {{\u003c wp VIC_cipher fr \u003e}}\n* {{\u003c wp VIC_cipher \"\" fr \u003e}}\n* {{\u003c wp VIC_cipher \"VIC Cipher\" \u003e}}\n* {{\u003c wp VIC_cipher \"VIC Cipher\" fr \u003e}}\n\n``` html\n\u003ca href=\"https://en.wikipedia.org/wiki/VIC_cipher\"\u003eVIC_cipher\u003c/a\u003e\n\u003ca href=\"https://fr.wikipedia.org/wiki/VIC_cipher\"\u003eVIC_cipher\u003c/a\u003e\n\u003ca href=\"https://fr.wikipedia.org/wiki/VIC_cipher\"\u003eVIC_cipher\u003c/a\u003e\n\u003ca href=\"https://en.wikipedia.org/wiki/VIC_cipher\"\u003eVIC Cipher\u003c/a\u003e\n\u003ca href=\"https://fr.wikipedia.org/wiki/VIC_cipher\"\u003eVIC Cipher\u003c/a\u003e\n```\n\nIt does not remove the underlines from tag to use in title. I have not found a\nHugo template function for that yet (perhaps there is one).\n\n### Octopress blockquote (blockquote.html)\nPort of the Octopress `blockquote` plugin at\nhttp://octopress.org/docs/plugins/blockquote/.\n\nIt supports author, link, source and title. If title is not provided and link is\nlonger than 32 characters, it is cut at the last forward slash similar to the\noriginal plugin.\n\nIt can be used as follows (also in `tests/wp-test.markdown`):\n\n    Normal quote:\n    {{\u003c blockquote \u003e}}\n      This is a simple quote.\n    {{\u003c /blockquote \u003e}}\n\n    Quote with author\n    {{\u003c blockquote author=\"Author2\" \u003e}}\n      This is a quote with only an Author named Author2.\n    {{\u003c /blockquote \u003e}}\n\n    Quote with author and source\n    {{\u003c blockquote author=\"Author3\" source=\"Source\" \u003e}}\n      This is a quote from Author3 and source \"source.\"\n    {{\u003c /blockquote \u003e}}\n\n    Quote with author and link\n    {{\u003c blockquote author=\"Author4\" link=\"https://www.google.com\" \u003e}}\n      This is a quote from Author4 and links to https://www.google.com.\n    {{\u003c /blockquote \u003e}}\n\n    Quote with author, link and title\n    {{\u003c blockquote author=\"Author5\" link=\"https://www.google.com\" title=\"Google\" \u003e}}\n      This is a quote from Author5 and links to https://www.google.com with title \"Google.\"\n    {{\u003c /blockquote \u003e}}\n\n    Quote with author and a link longer than 32 characters, string is first cut at 32 characters then everything after the last forward slash is removed\n    {{\u003c blockquote author=\"Author6\" link=\"https://twitter.com/CryptoGangsta/status/716427930126196737\" \u003e}}\n      This is a quote from Author5 and links to https://twitter.com/CryptoGangsta/status/716427930126196737 which is longer than 32 characters.\n      \u003cbr\u003eAnd this is a new line in the quote with the HTML br tag.\n    {{\u003c /blockquote \u003e}}\n\n    Test from the Octopress blockquote page at: http://octopress.org/docs/plugins/blockquote/\n    {{\u003c blockquote author=\"@allanbranch\" link=\"https://twitter.com/allanbranch/status/90766146063712256\" \u003e}}\n      Over the past 24 hours I've been reflecting on my life \u0026 I've realized only one thing. I need a medieval battle axe.\n    {{\u003c /blockquote \u003e}}\n\nResults in:\n\n![blockquote-test](images/blockquote.png)\n\n### Year (year.html)\nDisplays the current year - based on the shortcode tutorial at\nhttps://gohugo.io/templates/shortcode-templates/#single-word-example-year.\n\nUsage: `{{\u003c year \u003e}}`.\n\n### abbr HTML Tag (abbr.html)\nCreates an `abbr` HTML tag. The structure for this tag looks like:\n\n```html\n\u003cabbr title=\"World Health Organization\"\u003eWHO\u003c/abbr\u003e\n```\n\nWhich is created by the following shortcode:\n\n`{{\u003c abbr title=\"World Health Organization\" text=\"WHO\" \u003e}}`\n\n### mark HTML Tag (mark.html)\nCreates a `mark` HTML tag to highlight text.\n\nUsage: `{{\u003c mark text=\"highlighted text\" \u003e}}` results in the following HTML:\n\n`\u003cmark\u003ehighlighted text\u003c/mark\u003e`\n\n### Table of Contents (toc.html)\nUse it to insert a table of contents anywhere in your page. For more information\nabout Hugo's table of contents please see\nhttps://gohugo.io/content-management/toc/.\n\nUsage: `{{\u003c toc \u003e}}`.\n\n**Note for Goldmark users:** \n\nStarting with Hugo 0.60 (I think?), the configuration file has a new section\nnamed `markup`. We can specify the minimum and maximum heading levels in the\ntable of contents. The defaults are as follows which are not that useful. Be\nsure to override them in your site's config file:\n\n```yaml\nmarkup:\n  tableOfContents:\n    endLevel: 3\n    ordered: false\n    startLevel: 2\n```\n\nFor more information please see\nhttps://gohugo.io/getting-started/configuration-markup/#table-of-contents.\n\n### xref (xref.html)\nAdds text to the input params to create a relref link for my blog. It adds\nhardcoded strings to the path to work with the way I organize my paths. It might\nnot be useful for you.\n\nThese two are identical\n\n```\n{{\u003c xref text=\"Brief Recon of the Nordpass Password Manager\"\n  path=\"/post/2021/2021-04-30-testing-extensions-edge/\" anchor=\"brief-recon\"\n  title=\"Brief Recon\" \u003e}}\n```\n\ninstead of \n\n```\n[Brief Recon of the Nordpass Password Manager]\n  ({{\u003c relref \"/post/2021/2021-04-30-testing-extensions-edge/index.markdown#brief-recon\" \u003e}}\n  \"Brief Recon)\n```\n\nWe can also use positional arguments.\n\n```\n{{\u003c xref \"path\" \"text\" \"title\" \"anchor\" \u003e}}\n\n{{\u003c xref \"/post/2021/2021-04-30-testing-extensions-edge/\" \"brief-recon\"\n  \"Brief Recon of the Nordpass Password Manager\" \"Brief Recon\" \u003e}}\n```\n\nWith positional arguments, we cannot skip arguments. E.g., we can have path and\nanchor but not\n\n```\n{{\u003c xref \"/post/2021/2021-04-30-testing-extensions-edge/\" \u003e}}\n\n{{\u003c xref \"/post/2021/2021-04-30-testing-extensions-edge/\" \"brief-recon\" \u003e}}\n```\n\n#### Path\n\n* Path is passed to the relref link so it will panic if the path does not exist.\n* If the path does not end in `.md` or `.markdown` it adds `/index.markdown` to\n  the end of it to support page bundles.\n* Don't worry about including `/` at the beginning or in the end, the shortcode\n  removes them and adds its own.\n\n#### Anchor\n\n* Link's anchor.\n* Optional.\n* No need to include `#` but if included it will not introduce a bug. The\n  shortcode trims it and adds its own.\n\n#### Text\n\n* The link's text.\n* Optional.\n* If not provided, the text will be the same as the link. I.e.,\n  `.Site.BaseURL/$relreflink`.\n\n#### Title\n\n* The text that appears on the mouse tooltip when it's over the link. The\n  `title` HTML attribute for the `a` tag.\n* Optional.\n* If not provided, it will be the same as text.\n\n----------\n\n## Editor Snippets\nI have created snippets for Atom, Sublime and VS Code.\n\n### Sublime Text Completions\n[Sublime text completions](http://docs.sublimetext.info/en/latest/reference/completions.html)\nare stored in a `.sublime-completion` file in the `User` directory.\n\n### VS Code Snippets\n[VS Code snippets](editor-snippets/vs-code-markdown.json) can be added to\n`File \u003e Preferences \u003e User Snippets \u003e markdown.json`. For more information\nplease see:\n\n* https://code.visualstudio.com/docs/editor/userdefinedsnippets\n\n### Atom Snippets - Archived\n~~I use Atom editor these days so~~ I created a couple of snippets to insert\nthese shortcodes while editing Markdown files. In order to read on how to create\nsnippets please refer to\n[Atom's Snippets package](https://github.com/atom/snippets).\n\nOpen your snippets file (on Windows it's `File \u003e Open Your Snippets`) and paste the `editor-snippets\\atom-snippets.cson` into it.\n\nMy original mistake was to repeat `'.source.gfm'` before the `imgcap` snippet,\nseems like\n[cson keys should not be repeated](https://atom.io/docs/latest/using-atom-basic-customization#id-D9ATX).\n\nFor more information please see:\n\n* https://flight-manual.atom.io/using-atom/sections/snippets/\n\n## License\nI don't know, [MIT](LICENSE) I guess.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparsiya%2Fhugo-shortcodes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparsiya%2Fhugo-shortcodes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparsiya%2Fhugo-shortcodes/lists"}