Skip to content
ffflorianPublic

About

A simple links theme for Hugo built with Tailwind CSS. Fixed and improved.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Lynx

This is a fork of the original Lynx theme, fixed for Hugo >= 0.146.0 and improved.


Lynx is designed to be a simple links page powered by Hugo. It's built using Tailwind CSS and inspired by services like LinkTree.

πŸ”— Live preview πŸ› Bug reports & issues πŸ’‘ Questions & feature requests

Screenshot

Features

  • Fully responsive layout built with Tailwind CSS 4
  • Dark mode that follows the system preference, with a toggle that lets visitors switch it on and off (optional)
  • 40+ built-in link styles with SVG icons from FontAwesome 5, plus support for custom icons and link styles
  • HTML and Emoji support
  • Fathom Analytics and Google Analytics support
  • Favicons support
  • Translations (English and French)
  • Accessible to screen reader users: alt texts, skip link, list semantics, new-tab announcements and visible keyboard focus

Installation

Lynx supports several installation methods - as a Hugo Module (easiest), a git submodule, or as a completely manual install.

Below is a quick start guide using Hugo modules.

Quick start using Hugo

Note: Ensure you have Go and Hugo installed, and that you have created a new Hugo project before proceeding.

  1. From your project directory, initialise Hugo Modules:

    hugo mod init github.com/<username>/<repo-name>
  2. Create config/_default/module.toml and add the following:

    [[imports]]
    path = "github.com/ffflorian/lynx"
  3. Start your server using hugo server and the theme will be downloaded automatically.

  4. In the root folder of your website, replace the config.toml file that was generated by Hugo with the one from Lynx. You will find the theme config file in the Hugo cache directory, or download a copy from GitHub.

  5. Follow the configuration instructions below.

Installing theme updates

New versions are published as GitHub releases following Semantic Versioning. All changes are listed in the changelog.

To update the theme, run hugo mod get -u from your project directory and the theme will automatically update to the latest release.


Configuration

The main theme configuration is managed in the config.toml file. Most parameters are self explanatory and the default config contains some basic examples.

The author name and image are displayed at the top of the page. Both are optional and will default to the site title with no image when not provided.

Use imageAlt to describe the author image for screen reader users. When it is not set, the author name is used. Set it to an empty string (imageAlt = "") if the image is purely decorative.

[params.author]
name = "Jane Doe"
image = "img/author.jpg"
imageAlt = "Jane Doe smiling in front of a bookshelf"

Links can either be a simple string containing the URL for the link, or an object that defines the link parameters. Links are displayed in the order provided in the config file.

Acceptable link parameters are:

  • href = the URL the link should point to (required)
  • icon = the name of the icon to use for this link
  • text = the link text
  • target = the target of the link (default: _blank)
  • title = the HTML title of the link
  • label = an accessible name for screen readers (aria-label), used instead of the link text. It should include the visible link text, e.g. label = "My projects on GitHub" for a link with the text GitHub.

Icons next to links are decorative and hidden from screen readers. Links that open in a new tab are announced as such to screen reader users.

[params.author]
links = {
   # Simple link
   { github = "https://github.com/ffflorian/lynx" }

   # Custom link
   { github = { href = "https://github.com/ffflorian/lynx", text = "GitHub Project" } }
}

Dark mode follows the visitor's system preference by default. A toggle button in the top right corner lets visitors switch dark mode on and off; their choice is remembered in the browser. To hide the toggle, set darkModeToggle = false:

[params]
darkModeToggle = false

Additional page content can be provided by creating a Markdown file at content/_index.md. The contents of this file will be displayed between the title and links. Check out the exampleSite to see this in practice.

Images in Markdown content get their alt text from the standard Markdown syntax: ![A lynx sitting in the grass](lynx.jpg). Icons inserted with the icon shortcode are decorative by default; pass a second argument to give them alt text: {{</* icon "github" "GitHub" */>}}.

Basic content pages can also be created by placing Markdown files in the content directory. These can then be linked to using links in the config file or through the homepage content.

Adding custom icons and link styles

Lynx supports adding your own SVG icons and link styles to fully customise your links page. In the root of your Hugo project, simply create an assets folder and add your assets. Icons should be placed in an icons folder and any CSS should be in a file named css/custom.css.

The custom CSS file will automatically be included and minified when the site is built. The styles can be as creative as you wish and anything in your custom CSS will override the default theme.

If you need icons, you can find free SVG icons for many services at FontAwesome.

Example

Let's make a custom link for FontAwesome using the FA flag as the link icon and a gradient background as the link style.

If you prefer to inspect the code, the exampleSite contains a custom link to FontAwesome that demonstrates this process.

  1. Place the SVG icon in the icons folder /assets/icons/font-awesome.svg.

  2. Create the CSS file at /assets/css/custom.css and add in a rule to style the link:

    .link-font-awesome {
      background: rgb(131, 58, 180);
      background: linear-gradient(90deg, rgba(131, 58, 180, 1) 0%, rgba(253, 29, 29, 1) 50%, rgba(252, 176, 69, 1) 100%);
    }

    Note: The CSS class name should be the icon name prefixed with link-.

  3. Finally, in the config.toml file, create the link by referencing the new icon:

    font-awesome = { href = "https://fontawesome.com", text = "FontAwesome" }

When the site is rebuilt, the new custom link will appear.


Contributing

Lynx is expected to evolve over time. I intend to keep adding features and making changes as required.

Feel free to get in touch with any issues or suggestions for new features you'd like to see.

If you're able to fix a bug or implement a new feature, I welcome PRs for this purpose. Learn more in the contributing guidelines.

About

A simple links theme for Hugo built with Tailwind CSS. Fixed and improved.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages