× Search About Posts Code Music Links
Blank Try
experiment
lots
learn
more

Gists and Snippets

Updated on
Last site update: 8 May 2024

So this page is using the built in Hugo shortcode gist. It inserts the github script tag to pull the data from a GitHub gist. The file used is a list of links written in markdown.

This means you don’t need to rebuild the site to update the gist. A simple pagre refresh will do.

It also means you have no control over the HTML or styling of the gist’s content.

view raw links.md hosted with ❤ by GitHub

Alternatives

Instead of using markdown use HTML. You can add a css file to the gist but obviously this would be the same in every web site.

Another way might be to is to embed a git repo in your page.

There are different methods: you could use an iframe but the styling could not be used from the site in which is is embedded.

Maybe pull the repo like you do with a theme using git clone or git submodules. Submodules is always up to date (after a site rebuild I assume). This could be incorporated into a partial or shortcode.

GitLab Snippet

Just testing this html snippet

1 2 3
<p>This is a public snippet encoded in html</p>

<h2> this is a heading</h2>

What’s interesting is that it has picked up the CSS background colour for the pre and or code tags.

To allow these to get the embed code they have to be saved as public in GitLab.

GitLab markdown

1 2 3 4 5 6 7 8 9 10 11 12 13 14
This is the about page. It has an embedded stylesheet.

This test it to see how one could create a simple website from markdown files in GitLab Snippets.

You can create multiple snippets (up to 10) and link together just using the file names as links.


[home](home.md) | About | [Questions](another.md)

<style>
body {
    color: orange;
}
</style>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Yet *another* page in this mini markdown website.

1. How do you embed a snippet in a web page. Would you even want to?
2. Are gists available to anyone or just logged in Github users?

<h2>Is html rendered in here? yes</h2>

That was an `h2` tag above

## codefences test

```css
body {
    display: grid;
    grid-template-rows: auto 1fr auto;
}
```

[home](home.md) | [About](about.md) | Questions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# Mini Markdown website

This is to see how markdown is rendered. This may depend on browser extensions.

1. SNIPPETS can only be viewed by other GitLab users that are logged in. This limits their use. 
2. HTML, including embedded stylesheets work.
3. Exernal links may be used.
4. They are version controlled & I'm not sure that can be turned off.

## Advantages?

The Advantages are they're quick(ish) and don't require an upload.



Another link to [Ebuyer](https://www.ebuyer.com/)

home | [About](about.md) | [Questions](another.md)
  1. Hugo docs on gist shortcode
  2. GitLab docs on Snippets
view raw links.md hosted with ❤ by GitHub