Hugo W3 Simple Theme Shortcodes Demo
On this page
I made the Hugo W3-Simple Theme based on W3.css from W3schools because I think W3.css is very powerful and fast CSS Framework. (It is much smaller than Bootstrap css)
I just went to Miniwebtool Character Counter to compare both css. W3.css is just less than 20% of Bootstrap.min.css file size.
I am not very familiar with Bootstrap.min.css. But I think W3.css is more than enough to build a blog-style website.
So I made this project and will keep updating.
Just finished some shortcodes functions.
This article is about the demo of these shortcodes.
Info Shortcodes
We can easily display info with this code below on markdown file
{{< info >}}
Blue often indicates a neutral informative change or action.
{{</info >}}
It will display default title with
Information!:You can set title with the following code:
{{< info title="W3.CSS is a CSS Framework!">}}
W3.CSS is a modern CSS framework with built-in responsiveness. It supports responsive mobile first design by default, and it is smaller and faster than similar CSS frameworks.
{{< /info >}}
It will display the title with your set:
Warning Shortcodes
We can easily display warning with this code below on markdown file
{{< warning >}}
Yellow often indicates a warning that might need attention.
{{</warning >}}
It will display default title with
Warning!:You can set title with the following code:
{{< warning title="Do Not Bypass This Theme!">}}
W3-simple is a Hugo theme powered by W3.css!
{{< /warning >}}
It will display the title with your set:
Colorcode shortcodes
W3-simple theme use w3colorcode.js to display code colors.
To use this function, you should add w3codecolor: true to your post.
Although w3colorcode.js is much smaller than other js, but it is still more than 20kb. So I do not want every page include this js file if no need.
w3colorcode.js is also built by W3school
It supports html, js, java, css, sql, python at this moment.
I just changed a little to add support to bash script.
bash Highlight
Colorcode shortcodes use mode and title to set up parameters. if not set, default color mode is bash and no title.
{{< colorcode >}}
your code here
{{</colorcode >}}
The demo for default colorcode shortcodes:
To install w3-simple theme, just use the command below
cd themes
git clone https://github.com/jesselau76/hugo-w3-simple.git
html Highlight
{{< colorcode mode="htmlHigh" title="Demo for html color" >}}
your code here
{{</colorcode >}}
<!DOCTYPE html>
<html>
<title>HTML Tutorial</title>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
css Highlight
{{< colorcode mode="cssHigh" title="Demo for css color" >}}
your code here
{{</colorcode >}}
body {
background-color: #d0e4fe;
}
h1 {
color: orange;
text-align: center;
}
p {
font-family: "Times New Roman";
font-size: 20px;
}
javascript Highlight
{{< colorcode mode="jsHigh" title="Demo for js color" >}}
your code here
{{</colorcode >}}
function w3CodeColor() {
var x, i, j, k, l, modes = ["html", "js", "java", "css", "sql", "python"];
if (!document.getElementsByClassName) {return;}
k = modes.length;
for (j = 0; j < k; j++) {
x = document.getElementsByClassName(modes[j] + "High");
l = x.length;
for (i = 0; i < l; i++) {
x[i].innerHTML = w3CodeColorize(x[i].innerHTML, modes[j]);
}
}
}
sql Highlight
{{< colorcode mode="sqlHigh" title="Demo for sql color" >}}
your code here
{{</colorcode >}}
SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;
python Highlight
{{< colorcode mode="pythonHigh" title="Demo for python color" >}}
your code here
{{</colorcode >}}
import json
# some JSON:
x = '{ "name":"John", "age":30, "city":"New York"}'
# parse x:
y = json.loads(x)
# the result is a Python dictionary:
print(y["age"])
quote shortcode
We can display quotes with shortcodes
{{< quote >}}
Make it as simple as possible, but not simpler.
{{< /quote >}}
It will display quote with default width 100% style and no author:
Make it as simple as possible, but not simpler.
You can also set width and author with shortcodes:
{{< quote width="61.8%" author="Albert Einstein" >}}
Make it as simple as possible, but not simpler.
{{< /quote >}}
Make it as simple as possible, but not simpler.
Or you can set px to width
{{< quote width="300px" author="Albert Einstein" >}}
Make it as simple as possible, but not simpler.
{{< /quote >}}
Make it as simple as possible, but not simpler.
Comments