Hugo’s data Directory (featuring Nitter instances)
Updated  2023-February-11

Page contents

News

2022-August-5  Published this evolving⁠[1] article.

 

Hugo’s default directory structure

When you create a Hugo project with this command:

hugo new site directory-name --format=extension

For example:

hugo new site directory-name --format=yaml

This directory structure is created:

.
└── directory-name/
    ├── archetypes/
    ├── assets/
    ├── content/
    ├── data/
    ├── layouts/
    ├── public/
    ├── static/
    ├── themes/
    └── config.extension

 

💡
  • Possible values of extension are json, toml, yaml and yml.

  • You can think of config.extension as Hugo’s default data file.

 

About the data directory

In your Hugo layout files — including in your shortcodes — you can access the contents of a non-⁠config JSON, TOML, YAML or XML file by putting the file in your project’s data directory. For example:

.
└── directory-name/
    ├── archetypes/
    ├── assets/
    ├── content/
    ├── data/
    │   └── nitter.yaml     ⟵👀
    ├── layouts/
    ├── public/
    ├── static/
    ├── themes/
    └── config.yaml

 

To learn about this nitter.yaml file, see the next section.

To learn about the data directory, see…

 

Example

In July 2022, I started including Nitter links on some Infinite Ink portals. Nitter is a Twitter front-⁠end focused on privacy, which you can learn about at…

Because Nitter instances are often overloaded, I use Hugo’s shuffle function to select a random Nitter instance for each timeline that I link to. Below are the steps I used to set this up.

 

1. Create data/nitter.yaml

First, I created the following YAML⁠[2] file that lists Nitter instances.

data/nitter.yaml
## A line beginning with # is a comment and is ignored
instances:
 - nitter.net
 - nitter.42l.fr
# - nitter.pussthecat.org discontinued 2023-02-09
 - nitter.kavin.rocks
 - nitter.unixfox.eu
# - nitter.namazso.eu discontinued 2023-02-19
# - nitter.hu
 - nitter.moomoo.me
 - nitter.it
# - twitter.censors.us 2023-04-20 "Your connection is not private"
 - nitter.grimneko.de
# - nitter.ca  # discontinued 2022-11-26
 - nitter.fly.dev
 - notabird.site
 - nitter.weiler.rocks
 - nitter.sethforprivacy.com
# - nttr.stream
 - nitter.cutelab.space
 - nitter.nl
 - nitter.mint.lgbt
# - nitter.bus-hit.me 2022-12-04 "504 Gateway Time-Out"
 - nitter.esmailelbob.xyz
# - tw.artemislena.eu  2023-04-20 FAIL
# - de.nttr.stream  2022-08-21 offline
 - nitter.winscloud.net
 - nitter.tiekoetter.com
 - nitter.spaceint.fr
# - twtr.bch.bar
# - nitter.privacy.com.de  2022-10-15 "Instance has been rate limited"
# - nitter.mastodon.pro
# - nitter.notraxx.ch
 - nitter.poast.org
 - nitter.bird.froth.zone
 - nitter.dcs0.hu
 - twitter.dr460nf1r3.org
# - nitter.garudalinux.org  2023-04-23 "Verify you are human"
# - twitter.beparanoid.de #2023-04-20 redirected, than FAILed
# - n.ramle.be
 - nitter.cz
 - nitter.privacydev.net
 - tweet.lambda.dance
# - nitter.ebnar.xyz
 - nitter.kylrth.com
# - nitter.foss.wtf  discontinued 2023-04-13
# - nitter.priv.pw  2023-04-23 "Your connection is not private"
 - nt.vern.cc
# - nitter.wef.lol
 - nitter.tokhmi.xyz
 - nitter.catalyst.sx
 - unofficialbird.com
 - nitter.projectsegfau.lt
 - singapore.unofficialbird.com
# - twt.funami.tech
# - nitter.fprivacy.com
 - canada.unofficialbird.com
 - india.unofficialbird.com
 - nederland.unofficialbird.com
 - uk.unofficialbird.com
 - n.l5.ca
 - nitter.slipfox.xyz
 - nitter.soopy.moe
 - nitter.qwik.space
 - read.whatever.social
 - nitter.rawbit.ninja
 - nt.vern.cc
# - ntr.odyssey346.dev  # 2022-11-12 08:49:23 not working atm
 - nitter.ir
# - nitter.privacytools.io  2022-09-30 not working
 - nitter.sneed.network
 - n.sneed.network
# - nitter.manasiwibi.com  2023-04-23 "refused to connect"
 - nitter.smnz.de
# - nitter.twei.space  2023-04-20 "Verify you are human"
 - nitter.inpt.fr
# - nitter.d420.de 2022-10-16 said "Enable JavaScript ... to continue" wtf?
 - nitter.caioalonso.com
 - nitter.at
# - nitter.drivet.xyz 2023-02-22 not working
 - nitter.pw
 - nitter.nicfab.eu
# - bird.habedieeh.re 2022-12-30 redirected to Instances
 - nitter.hostux.net
 - nitter.adminforge.de
 - nitter.platypush.tech
# - nitter.mask.sh  2023-04-23 "Your connection is not private"
 - nitter.pufe.org
 - nitter.us.projectsegfau.lt
# - nitter.marcopisco.com
 - nitter.arcticfoxes.net
 - t.com.sb
# - nitter.selfhostable.net 2023-04-20 "404 Not Found"
# - bluebird.codeine.world
 - nitter.kling.gg
 - twt.funami.tech
 - nitter.ktachibana.party
 - nitter.riverside.rocks
# - bird.wilbvr.me
# - nitter.girlboss.ceo discontinued 2023-03-20
 - nitter.lunar.icu
 - twitter.moe.ngo
 - nitter.freedit.eu
 - ntr.frail.duckdns.org
 - nitter.us.projectsegfau.lt
 - nitter.librenode.org
 - n.opnxng.com
 - nitter.plus.st
 - nitter.in.projectsegfau.lt
 - nitter.tux.pizza
 - t.floss.media
 - twit.hell.rodeo
 - twt.funami.tech
 - nitter.nachtalb.io
 - n.quadtr.ee
 - nitter.altgr.xyz
 - jote.lile.cl
 - nitter.one
 - nitter.edist.ro
 - nitter.instance.no
 - nitter.simpleprivacy.fr
 - nitter.io.lol
 - nitter.hu
 - nitter.no-logs.com
 - tw.libb.pw
 - nitter.fascinated.cc

 

2. Create shortcode

Next, I created something like the following Hugo shortcode.

layouts/shortcodes/nitter-instance-of-nm-gohugo-list.html
To view @nm’s <em>gohugo</em> Twitter list on a random
<a href="https://github.com/zedeus/nitter/wiki/Instances">Nitter instance</a>,
go to
{{ range site.Data.nitter.instances | shuffle | first 1 -}}
 <a href="https://{{ . }}/nm/lists/gohugo">
  {{- . -}}/nm/lists/gohugo</a>.
{{ end }}

 

  • The bolded line uses Hugo’s contextless global site function[3] to access site.Data.nitter.instances.

  • In site.Data.whatever, Data must begin with upper case D and site must be all lower case.

 

3. Call shortcode

To call this shortcode in a content file, for example in the source of this article, I use the following syntax.

{{< nitter-instance-of-nm-gohugo-list >}}

 

4. Example rendering of shortcode

Here is how this shortcode is rendered on this build of this page:

To view @nm's gohugo Twitter list on a random Nitter instance, go to nitter.net/nm/lists/gohugo.

Note that each time that Hugo builds this Infinite Ink website, the Nitter instance (nitter.net in this case)  changes.

 

See also

Endnotes


1. Many Infinite Ink articles, including this one, are evergreen and regularly updated.
3. You can tell that the Hugo site function is contextless by noticing that it does not have a leading dot (.). To learn about this global function, see the Hugo v0.53 release notes, especially the relevant GitHub commit and GitHub issues.

Discuss or share this page 📝 🤔 🐘