Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • Alexandre.Meyer/m1if37-animation
  • Alexandre.Meyer/m2-apprentissage-profond-image
  • Alexandre.Meyer/m2-animation
  • Alexandre.Meyer/hugo-web-minimal
  • Alexandre.Meyer/lifami
  • Alexandre.Meyer/lifapcd
  • Alexandre.Meyer/www
  • Alexandre.Meyer/lifstage
8 results
Show changes
Showing
with 0 additions and 703 deletions
# Hugo Flex
A lightweight Hugo theme leveraging CSS Flexbox.
This theme is verified to work with Hugo versions v0.65–v0.104.
## Features
- Flexbox-based responsive layout
- 100% speed score on PageSpeed Insight
- No framework
- No javascript
- Full posts in RSS feed
- RSS page looks like a normal page
Optional features:
- Show summaries on homepage
- Schema.org, Open Graph and Twitter Cards metadata
- Utterances comments widget
- Custom CSS and JS may be added [site-wide](#custom-css-and-js), or [dynamically](#dynamically-embedded) with shortcodes
- Built-in shortcodes:
- Netlify contact form
- On-click Soundcloud player
## Example
The [demo site](https://de-souza.github.io/hugo-flex/) is built from the [hugoBasicExample](https://github.com/gohugoio/hugoBasicExample) repository.
A complete starter template specifically made for this theme is also available at [scivision/hugo-flex-example](https://github.com/scivision/hugo-flex-example).
## Installation
1. [Install Hugo](https://gohugo.io/getting-started/installing/).
2. [Create a Hugo site](https://gohugo.io/getting-started/quick-start/).
3. Open a command prompt at the root of the site and download the theme:
```bash
git init
git submodule add https://github.com/de-souza/hugo-flex.git themes/hugo-flex
```
4. Add the theme to the site configuration:
```bash
echo 'theme: hugo-flex' >> config.yaml
```
## Updating
Open a command prompt at the root of the site and update the theme:
```bash
git submodule update --remote --rebase
```
## Configuration
Any part of the default theme configuration can be overwritten in the site configuration:
```yaml
params:
color: teal # Any color in CSS syntax
width: 42rem # Any length in CSS syntax
footer: >- # HTML spaces ( ) are needed before HTML elements
Except where otherwise noted, content on this site is licensed under a  
<a href="http://creativecommons.org/licenses/by/4.0/" rel="license">Creative
Commons Attribution 4.0 International License</a>.
rss: To subscribe to this RSS feed, copy its address and paste it into your
favorite feed reader.
summaries: false # Set to true to show summaries of posts on homepage
divider: \a0 # Set to false to remove divider below posts on homepage
schema: false # Set to true to add Schema.org metadata
opengraph: false # Set to true to add Open Graph metadata
twittercards: false # Set to true to add Twitter Cards metadata
utterances:
repo: # Set to Utterances repo URL to add Utterances comments
issueterm: pathname
theme: github-light
netlify:
honeypot: false # Set to true to add honeypot field in contact form
recaptcha: false # Set to true to add recaptcha challenge in contact form
# css: # Uncomment to add custom CSS from the assets directory
# - css/foo.css
# - bar.css
# js: # Uncomment to add custom JS from the assets directory
# - js/foo.js
# - bar.js
menu:
nav:
- name: About
url: about/
weight: 1
- name: Posts
url: post/
weight: 2
- name: Tags
url: tags/
weight: 3
- name: Categories
url: categories/
weight: 4
- name: RSS
url: index.xml
weight: 5
```
## Built-In Shortcodes
### Netlify Contact Form
A contact form working with the Netlify form handling service may be inserted with the shortcode:
```
{{< contact >}}
```
A custom success page URL may be given as a parameter:
```
{{< contact "/success" >}}
```
### Soundcloud Player
A Soundcloud Player may be inserted with the shortcode:
```
{{< soundcloud 123456789 >}}
```
The parameter is a track ID that can be extracted from the "embed" sharing menu on the track page.
## Custom CSS and JS
### Site-Wide
Custom CSS and JS can be added to all the site pages at once. To do so, their filenames can be added to the site configuration:
```yaml
params:
css:
- css/foo.css
- bar.css
js:
- js/foo.js
- bar.js
```
The paths are relative to the project working directory.
In this example, the file paths relative to the site root would be `assets/css/foo.css`, `assets/bar.css`, `assets/js/foo.js`, `assets/bar.js`.
### Dynamically Embedded
CSS and JS resources may be embedded on specific pages of the site using [shortcodes](https://gohugo.io/content-management/shortcodes).
To load a resource on each page where a shortcode is used, the template for this shortcode must add the resource to the `css` or `js` key of the `.Scratch` variable. For instance, a shortcode template `myshortcode.html` containing the line
```html
{{ resources.Get "myscript.js" | fingerprint | .Page.Scratch.SetInMap "js" "myscript" }}
```
will load `myscript.js` on every page where `myshortcode` is used.
As an example, this is the template for the built-in Soundcloud shortcode:
```html
{{ resources.Get "css/soundcloud.css" | minify | fingerprint | .Page.Scratch.SetInMap "css" "soundcloud" }}
{{ resources.Get "js/soundcloud.js" | minify | fingerprint | .Page.Scratch.SetInMap "js" "soundcloud" }}
<div class="Soundcloud" data-id="{{ .Get 0 }}"></div>
```
## License
This theme is licensed under the [Apache License 2.0](https://github.com/de-souza/hugo-flex/blob/master/LICENSE).
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
line-height: 1.6;
display: flex;
flex-direction: column;
min-height: 100vh;
margin: 0;
padding: 0;
}
main {
flex-grow: 1;
}
img {
max-width: 100%;
border-radius: 0.2rem;
}
pre {
overflow-x: auto;
border: 0.1rem solid lightgray;
padding: 1rem;
}
code {
font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
}
.Banner {
list-style: none;
display: flex;
flex-flow: row-reverse wrap-reverse;
justify-content: space-between;
margin: 0;
padding: 0;
}
{{ $len := len site.Menus.nav }}
{{ range seq $len }}
.Banner-item:nth-child({{ . }}) {
order: {{ sub $len . | add 1 }};
}
{{ end }}
.Banner-item--title {
flex-grow: 1;
}
.Banner-link {
font-size: 1.25rem;
color: white;
padding: 0.5rem 1rem;
}
.Heading {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: baseline;
}
.Heading-title {
margin: 1.5rem 0.5rem 0 0;
}
.Heading-link {
color: inherit;
}
.Tags {
list-style: none;
display: flex;
flex-wrap: wrap;
justify-content: center;
margin: 1.5rem 0;
padding: 0;
}
.Tags-item {
border-radius: 0.2rem;
margin: 0.2rem;
padding: 0 0.3rem;
}
.Tags-link {
color: white;
}
{{ with site.Params.divider }}
.Divider {
display: flex;
justify-content: center;
}
.Divider::after {
content: "{{ . }}";
}
{{ end }}
.Pagination {
font-size: 1.25rem;
color: inherit;
}
.Pagination--right {
float: right;
}
.Footer {
text-align: center;
margin: 1rem 0;
}
.u-wrapper {
{{ with site.Params.width }}max-width: {{ . }};{{ end }}
margin: auto;
}
.u-padding {
padding: 0 1rem;
}
.u-background {
background: {{ site.Params.color }};
}
.u-clickable {
font-weight: bold;
text-decoration: none;
display: inline-block;
}
.Contact {
max-width: 30rem;
margin: 1.5rem auto;
}
.Contact-group {
list-style-type: none;
margin: 0;
padding: 0;
}
.Contact-hidden {
display: none;
}
.Contact-item {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin: 0.5rem 0;
}
.Contact-label {
flex-basis: 5rem;
}
.Contact-input {
flex-grow: 1;
flex-basis: 15rem;
}
.Contact-input--textbox {
resize: vertical;
height: 5rem;
}
.Contact-button {
margin-left: auto;
}
.Soundcloud {
height: 166px;
}
.Soundcloud:empty {
display: none;
}
.Soundcloud-iframe {
height: 100%;
width: 100%;
border: 0;
}
.Soundcloud-player {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
border: 0.1rem solid lightgray;
border-radius: 0.3rem;
background: whitesmoke;
cursor: pointer;
}
const soundcloud = (() => {
for (const wrapper of document.querySelectorAll(".Soundcloud")) {
const iframe = document.createElement("iframe");
iframe.className = "Soundcloud-iframe";
iframe.setAttribute("src", `https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/${wrapper.getAttribute('data-id')}&show_comments=false`);
const link = document.createElement("a");
link.setAttribute("href", "https://soundcloud.com/pages/cookies");
link.textContent = "cookie policy";
link.onclick = e => e.stopPropagation();
link.onkeydown = e => e.stopPropagation();
const player = document.createElement("div");
player.className = "Soundcloud-player";
player.setAttribute("tabindex", "0");
player.textContent = 'Load player';
player.appendChild(link);
player.onclick = () => wrapper.replaceChild(iframe, player);
player.onkeydown = e => { if (e.keyCode == 13) wrapper.replaceChild(iframe, player) };
wrapper.appendChild(player);
};
})();
{{ safeHTML `<?xml version="1.0" encoding="utf-8" ?>` }}
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" doctype-system="about:legacy-compat" />
<xsl:template match="/rss/channel">
<html lang="{{ site.LanguageCode }}">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{{ hugo.Generator }}
<title><xsl:value-of select="title" /></title>
{{ $site_css := (.Scratch.Get "css").base }}
<link rel="stylesheet" href="{{ $site_css.Permalink }}" integrity="{{ $site_css.Data.Integrity }}" />
</head>
<body>
<nav class="u-background">
<div class="u-wrapper">
<ul class="Banner">
<li class="Banner-item Banner-item--title">
<a class="Banner-link u-clickable" href="{{ absURL nil }}">{{ site.Title }}</a>
</li>
{{ range site.Menus.nav }}
<li class="Banner-item">
<a class="Banner-link u-clickable" href="{{ absURL .URL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>
</div>
</nav>
<main>
<div class="u-wrapper">
<div class="u-padding">
<h2 class="Heading-title">
<a class="Heading-link u-clickable" href="{link}" rel="bookmark"><xsl:value-of select="title" /></a>
</h2>
{{ with site.Params.rss }}
<p>
{{ safeHTML . }}
</p>
{{ end }}
</div>
</div>
</main>
{{ with site.Params.footer }}
<footer class="Footer">
<div class="u-wrapper">
<div class="u-padding">
{{ safeHTML . }}
</div>
</div>
</footer>
{{ end }}
</body>
</html>
</xsl:template>
</xsl:stylesheet>
params:
color: teal # Any color in CSS syntax
width: 42rem # Any length in CSS syntax
footer: >- # A hardcoded space is needed before each html element
Except where otherwise noted, content on this site is licensed under a &#32;
<a href="http://creativecommons.org/licenses/by/4.0/" rel="license">Creative
Commons Attribution 4.0 International License</a>.
rss: To subscribe to this RSS feed, copy its address and paste it into your
favorite feed reader.
summaries: false # Set to true to show summaries of posts on homepage
divider: \a0 # Set to false to remove divider below posts on homepage
schema: false # Set to true to add Schema.org metadata
opengraph: false # Set to true to add Open Graph metadata
twittercards: false # Set to true to add Twitter Cards metadata
utterances:
repo: # Set to Utterances repo URL to add Utterances comments
issueterm: pathname
theme: github-light
netlify:
honeypot: false # Set to true to add honeypot field in contact form
recaptcha: false # Set to true to add recaptcha challenge in contact form
# css: # Uncomment to add custom CSS from a list of files
# - css/foo.css
# - bar.css
# js: # Uncomment to add custom JS from a list of files
# - js/foo.js
# - bar.js
menu:
nav:
- name: About
url: about/
weight: 1
- name: Posts
url: posts/
weight: 2
- name: Tags
url: tags/
weight: 3
- name: Categories
url: categories/
weight: 4
- name: RSS
url: index.xml
weight: 5
\ No newline at end of file
web/themes/hugo-flex/images/screenshot.png

49 KiB

web/themes/hugo-flex/images/tn.png

35.9 KiB

<!DOCTYPE html>
<html lang="{{ site.LanguageCode }}">
<head>
{{ partial "meta.html" . }}
{{ partial "title.html" . }}
{{ partial "link.html" . }}
{{ partial "load_site_assets.html" . }}
{{ block "load_page_assets" . }}
{{ with .Content }}{{ end }}
{{ end }}
{{ partial "assets.html" . }}
</head>
<body>
{{ partialCached "banner.html" . }}
<main>
<div class="u-wrapper">
<div class="u-padding">
{{ block "main" . }}{{ end }}
</div>
</div>
</main>
{{ partialCached "footer.html" . }}
</body>
</html>
{{ define "load_page_assets" }}
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
{{ with .Content }}{{ end }}
{{ $page_css := .Scratch.Get "css" }}
{{ with $page_css }}
{{ $css_list := $.Scratch.Get "css" }}
{{ . | merge $css_list | $.Scratch.Set "css" }}
{{ end }}
{{ $page_js := .Scratch.Get "js" }}
{{ with $page_js }}
{{ $js_list := $.Scratch.Get "js" }}
{{ . | merge $js_list | $.Scratch.Set "js" }}
{{ end }}
{{ end }}
{{ $paginator | .Scratch.Set "paginator" }}
{{ end }}
{{ define "main" }}
{{ $paginator := .Scratch.Get "paginator" }}
{{ range $paginator.Pages }}
<article>
{{ partial "heading.html" . }}
{{ if site.Params.summaries }}
{{ .Summary }}
{{ if .Truncated }}
<p>
<a class="u-clickable" href="{{ .RelPermalink }}">Read More…</a>
</p>
{{ end }}
{{ else }}
{{ .Content }}
{{ end }}
{{ partial "tags.html" . }}
</article>
{{ with site.Params.divider }}
<div class="Divider"></div>
{{ end }}
{{ end }}
{{ partial "pagination.html" . }}
{{ end }}
{{ define "main" }}
{{ partial "heading.html" . }}
{{ .Content }}
{{ range .Pages.GroupByPublishDate "2006" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
<li>
{{ .PublishDate.Format "2006-01-02" }} – <a href="{{ .RelPermalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}
{{ end }}
{{- $base_xml := resources.Get "xml/base.tpl.xml" | resources.ExecuteAsTemplate "xml/base.xml" . | minify }}
{{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
{{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }}
{{- $pages = $pages | first $limit }}
{{- end }}
{{- safeHTML `<?xml version="1.0" encoding="utf-8" ?>` }}
{{ printf `<?xml-stylesheet type="text/xsl" href=%q ?>` $base_xml.Permalink | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title site.Title }}{{ site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with site.LanguageCode }}
<language>{{ . }}</language>{{ end }}{{ with site.Author.email }}
<managingEditor>{{ . }}{{ with site.Author.name }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with site.Author.email }}
<webMaster>{{ . }}{{ with site.Author.name }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with site.Copyright }}
<copyright>{{ . }}</copyright>{{ end }}{{ with .Date | default nil }}
<lastBuildDate>{{ .Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}{{ with .OutputFormats.Get "RSS" }}
{{ printf `<atom:link href=%q rel="self" type=%q />` .Permalink .MediaType | safeHTML }}{{ end }}{{ range $pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>{{ with .PublishDate | default nil }}
<pubDate>{{ .Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>{{ end }}{{ with site.Author.email }}
<author>{{ . }}{{ with site.Author.name }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ .Permalink }}</guid>
<description>{{ html .Content }}</description>
</item>{{ end }}
</channel>
</rss>
{{ define "main" }}
<article>
{{ partial "heading.html" . }}
{{ .Content }}
{{ partial "tags.html" . }}
{{ partial "comments.html" . }}
</article>
{{ end }}
{{ define "main" }}
{{ partial "heading.html" . }}
{{ .Content }}
<ul class="Tags">
{{ range .Pages }}
<li class="Tags-item u-background">
<a class="Tags-link u-clickable" href="{{ .RelPermalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}
{{ range .Scratch.GetSortedMapValues "css" }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ range .Scratch.GetSortedMapValues "js" }}
<script defer src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
\ No newline at end of file
<nav class="u-background">
<div class="u-wrapper">
<ul class="Banner">
<li class="Banner-item Banner-item--title">
<a class="Banner-link u-clickable" href="{{ relURL nil }}">{{ site.Title }}</a>
</li>
{{ range site.Menus.nav }}
<li class="Banner-item">
<a class="Banner-link u-clickable" href="{{ relURL .URL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>
</div>
</nav>
\ No newline at end of file
{{ with site.Params.utterances }}
{{ if $.Type | in site.Params.mainSections | and .repo }}
<script src="https://utteranc.es/client.js" repo="{{ .repo }}" issue-term="{{ .issueterm }}" theme="{{ .theme }}" crossorigin="anonymous" async></script>
{{end}}
{{end}}
\ No newline at end of file
{{ with site.Params.footer }}
<footer class="Footer">
<div class="u-wrapper">
<div class="u-padding">
{{ safeHTML . }}
</div>
</div>
</footer>
{{ end }}
\ No newline at end of file
<header class="Heading">
<h2 class="Heading-title">
<a class="Heading-link u-clickable" href="{{ .RelPermalink }}" rel="bookmark">{{ .Title }}</a>
</h2>
{{ with .PublishDate | default nil }}
<time datetime="{{ .Format "2006-01-02T15:04:05Z07:00" }}">
{{- .Format "2 January, 2006" -}}
</time>
{{ end }}
</header>
\ No newline at end of file