Blog

Hugo Canonical

A canonical URL is the URL of the best representative page from a group of duplicate pages, according to Google. For example, if you have two URLs for the same page (such as example.com?dress=1234 and example.com/dresses/1234), Google chooses one as canonical. Similarly, if you have multiple pages that are nearly identical, Google can group them together (for example, pages that differ only by the sorting or filtering of the contents, such as by price or item color) and choose one as canonical. Google can only index the canonical URL from a set of duplicate pages.

Hugo Table

How to add a Table to Hugo

Create Table Shortcode

cat <<'EOF'> layouts/shortcodes/table.html    
{{ $htmlTable := .Inner | markdownify }} {{ $class := .Get 0 }} {{ $old := "<table>" }}
{{ $new := printf "<table class=\"%s\">" $class }} {{ $htmlTable :=
  replace $htmlTable $old $new }} {{ $htmlTable | safeHTML }}
</table>
EOF

Build Table

add this to your Markdown File …

| a | b | c |
| - | - | - |
| bli | bla | blu |
| green | blue | red |

Result

a b c
bli bla blu
green blue red

Align Left

| a | b | c |
| :- | :- | :- |
| bli | bla | blu |
| green | blue | red |

Result

a b c
bli bla blu
green blue red

Align Right

| a | b | c |
| -: | -: | -: |
| bli | bla | blu |
| green | blue | red |

Result

a b c
bli bla blu
green blue red

Any Comments ?

sha256: b0f3682d811304f9d60e0eb42ce92d7f28de15d6dbc0a9c35d1ce7937b442a60

Commento - Selfhosting Comment

Selfhosting Comment

some people mentioned that they can’t commment on some blogs. let’s change that, even there is not lot of feedback. i appreciate and read every comment and interaction with you, my readers.

poeple who knows me that i like todo most of the stuff self. so, i’d never buy a “service” for hosting some comments. i’ve got enough infrastructure running so i can host and operate it on my own.

Hugo - Start

GoHugo from Scratch

Take a fresh VM with OpenBSD ;) otherwise, you have to adapt appropriate …

install pkg

Login as User which is part of the “wheel group”. Doas should allow all Users of the Wheel Group to get root.

doas pkg_add hugo-- nginx--

adduser webmaster

create a user “webmaster” and prepare virtual directories

doas adduser webmaster
doas mkdir /var/www/virtual
doas chown webmaster /var/www/virtual/

Update Nginx

we need to modify nginx, prepare a site folder and a basic config for the webserver. do some stuff as root

Hugo Copy Button

I like Websites with the Copy Button for certain Snippets. Why not integrate into the own Blog ?

Folder, Copy JS Stuff

Change to Hugo Root Folder

mkdir -p static/js/

cat << 'EOF' > static/js/copy-code.js
(function() {
  'use strict';

  if(!document.queryCommandSupported('copy')) {
    return;
  }

  function flashCopyMessage(el, msg) {
    el.textContent = msg;
    setTimeout(function() {
      el.textContent = "Copy";
    }, 1000);
  }

  function selectText(node) {
    var selection = window.getSelection();
    var range = document.createRange();
    range.selectNodeContents(node);
    selection.removeAllRanges();
    selection.addRange(range);
    return selection;
  }

  function addCopyButton(containerEl) {
    var copyBtn = document.createElement("button");
    copyBtn.className = "highlight-copy-btn";
    copyBtn.textContent = "Copy";

    var codeEl = containerEl.firstElementChild;
    copyBtn.addEventListener('click', function() {
      try {
        var selection = selectText(codeEl);
        document.execCommand('copy');
        selection.removeAllRanges();

        flashCopyMessage(copyBtn, 'Copied!')
      } catch(e) {
        console && console.log(e);
        flashCopyMessage(copyBtn, 'Failed :\'(')
      }
    });

    containerEl.appendChild(copyBtn);
  }

  // Add copy button to code blocks
  var highlightBlocks = document.getElementsByClassName('highlight');
  Array.prototype.forEach.call(highlightBlocks, addCopyButton);
})();
EOF

Update Header

Open this File …

Comments

just trying a new feature for leaving comments … it’s selfhosted, done with isso and quite painfull to install :(

some people may like to provide feedback, ask questions, …


Any Comments ?

sha256: fed502f0a96744470fa42b910138efed8d462ce13a2f5329c61ad23fc133281e

Hugo Forms PHP

Wanna add some simple forms and process the Content with PHP ?

Add RawHTML Template

if not yet done

mkdir layouts/shortcodes/
cat << 'EOF' > layouts/shortcodes/rawhtml.html
<!-- raw html -->
{{.Inner}}
EOF

Create Script

cat << 'EOF' > static/welcome.php
<html>
<body>

Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>

</body>
</html>
EOF

Create new Post and add rawhtml

without " " between { and {

hugo new content/post/rawtest.md

vim content/post/rawtest.md

{ {<rawhtml>} }
<form action="/welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
{ {</rawhtml>} }

Example

Just a small Form Example

Name:
E-mail:

HugoIO Templates

Custom Template Stuff

mkdir -p layouts/shortcodes

cat << 'EOF' > layouts/shortcodes/date.html
{{ now.Format "2006-01-02 03:04:05" }}
EOF

Insert Code in Template

current date ? { {< date >} }

Result ?

current date ?? 2024-11-18 06:59:38

Add RawHTML

Create Template

cat << 'EOF' > layouts/shortcodes/rawhtml.html
<!-- raw html -->
{{.Inner}}
EOF

Add Code

{ {< rawhtml >} }
  <p class="speshal-fancy-custom">
    This is <strong>raw HTML</strong>, inside Markdown.
  </p>
{ {< /rawhtml >} }

Result ?

This is raw HTML, inside Markdown.

Dig Dns Whois

whois egal.com

user@erde$ whois egal.com
   Domain Name: EGAL.COM
   Registry Domain ID: 1979745_DOMAIN_COM-VRSN
   Registrar WHOIS Server: whois.name.com
   Registrar URL: http://www.name.com
   Updated Date: 2019-09-25T20:43:47Z
   Creation Date: 1996-03-25T05:00:00Z
   Registry Expiry Date: 2022-03-26T04:00:00Z
   Registrar: Name.com, Inc.
   Registrar IANA ID: 625
   Registrar Abuse Contact Email: [email protected]
   Registrar Abuse Contact Phone: 7202492374
   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
   Name Server: NS1CNY.NAME.COM
   Name Server: NS2KRY.NAME.COM
   Name Server: NS3DKZ.NAME.COM
   Name Server: NS4BHT.NAME.COM
   DNSSEC: unsigned
   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
>>> Last update of whois database: 2019-10-28T12:57:34Z <<<

For more information on Whois status codes, please visit https://icann.org/epp

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar.  Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability.  VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.
Domain Name: EGAL.COM
Registry Domain ID: 1979745_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.name.com
Registrar URL: http://www.name.com
Updated Date: 2019-09-25T20:43:47Z
Creation Date: 1996-03-25T05:00:00Z
Registrar Registration Expiration Date: 2022-03-26T04:00:00Z
Registrar: Name.com, Inc.
Registrar IANA ID: 625
Reseller:
Domain Status: clientTransferProhibited https://www.icann.org/epp#clientTransferProhibited
Registry Registrant ID: Not Available From Registry
Registrant Name: Domain Manager
Registrant Organization: Affordable Webhosting, Inc., Customers
Registrant Street: PO Box 1508
Registrant City: Manzanita
Registrant State/Province: OR
Registrant Postal Code: 97130-1508
Registrant Country: US
Registrant Phone: +1.8773593385
Registrant Email: [email protected]
Registry Admin ID: Not Available From Registry
Admin Name: Domain Manager
Admin Organization: Affordable Webhosting, Inc., Customers
Admin Street: PO Box 1508
Admin City: Manzanita
Admin State/Province: OR
Admin Postal Code: 97130-1508
Admin Country: US
Admin Phone: +1.8773593385
Admin Email: [email protected]
Registry Tech ID: Not Available From Registry
Tech Name: Domain Manager
Tech Organization: Affordable Webhosting, Inc., Customers
Tech Street: PO Box 1508
Tech City: Manzanita
Tech State/Province: OR
Tech Postal Code: 97130-1508
Tech Country: US
Tech Phone: +1.8773593385
Tech Email: [email protected]
Name Server: ns1cny.name.com
Name Server: ns2kry.name.com
Name Server: ns3dkz.name.com
Name Server: ns4bht.name.com
DNSSEC: unSigned
Registrar Abuse Contact Email: [email protected]
Registrar Abuse Contact Phone: +1.7203101849
URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/
>>> Last update of WHOIS database: 2019-10-28T12:57:49Z <<<

For more information on Whois status codes, please visit https://icann.org/epp

dig egal.com

user@erde$ dig egal.com

; <<>> DiG 9.4.2-P2 <<>> egal.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40487
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;egal.com.                      IN      A

;; ANSWER SECTION:
egal.com.               185     IN      A       75.126.102.240

;; Query time: 0 msec
;; SERVER: 192.168.108.211#53(192.168.108.211)
;; WHEN: Mon Oct 28 13:59:27 2019
;; MSG SIZE  rcvd: 42

dig -t SOA egal.com

user@erde$ dig -t SOA egal.com

; <<>> DiG 9.4.2-P2 <<>> -t SOA egal.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8267
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;egal.com.                      IN      SOA

;; ANSWER SECTION:
egal.com.               300     IN      SOA     ns1cny.name.com. support.name.com. 1571875200 10800 3600 604800 3600

;; Query time: 246 msec
;; SERVER: 192.168.108.211#53(192.168.108.211)
;; WHEN: Mon Oct 28 14:00:11 2019
;; MSG SIZE  rcvd: 82

dig -t SOA @ns1cny.name.com egal.com

user@erde$ dig -t SOA @ns1cny.name.com. egal.com.

; <<>> DiG 9.4.2-P2 <<>> -t SOA @ns1cny.name.com. egal.com.
; (2 servers found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13194
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;egal.com.                      IN      SOA

;; ANSWER SECTION:
egal.com.               300     IN      SOA     ns1cny.name.com. support.name.com. 1571875200 10800 3600 604800 3600

;; Query time: 31 msec
;; SERVER: 162.88.61.47#53(162.88.61.47)
;; WHEN: Mon Oct 28 14:01:25 2019
;; MSG SIZE  rcvd: 82

dig +trace @8.8.8.8 egal.com

user@erde$ dig +trace egal.com

; <<>> DiG 9.4.2-P2 <<>> +trace egal.com
;; global options:  printcmd
;; Received 17 bytes from 192.168.108.211#53(192.168.108.211) in 1 ms

user@erde$ dig +trace @8.8.8.8 egal.com

; <<>> DiG 9.4.2-P2 <<>> +trace @8.8.8.8 egal.com
; (1 server found)
;; global options:  printcmd
.                       12203   IN      NS      a.root-servers.net.
.                       12203   IN      NS      b.root-servers.net.
.                       12203   IN      NS      c.root-servers.net.
.                       12203   IN      NS      d.root-servers.net.
.                       12203   IN      NS      e.root-servers.net.
.                       12203   IN      NS      f.root-servers.net.
.                       12203   IN      NS      g.root-servers.net.
.                       12203   IN      NS      h.root-servers.net.
.                       12203   IN      NS      i.root-servers.net.
.                       12203   IN      NS      j.root-servers.net.
.                       12203   IN      NS      k.root-servers.net.
.                       12203   IN      NS      l.root-servers.net.
.                       12203   IN      NS      m.root-servers.net.
;; Received 228 bytes from 8.8.8.8#53(8.8.8.8) in 9 ms

com.                    172800  IN      NS      a.gtld-servers.net.
com.                    172800  IN      NS      b.gtld-servers.net.
com.                    172800  IN      NS      c.gtld-servers.net.
com.                    172800  IN      NS      d.gtld-servers.net.
com.                    172800  IN      NS      e.gtld-servers.net.
com.                    172800  IN      NS      f.gtld-servers.net.
com.                    172800  IN      NS      g.gtld-servers.net.
com.                    172800  IN      NS      h.gtld-servers.net.
com.                    172800  IN      NS      i.gtld-servers.net.
com.                    172800  IN      NS      j.gtld-servers.net.
com.                    172800  IN      NS      k.gtld-servers.net.
com.                    172800  IN      NS      l.gtld-servers.net.
com.                    172800  IN      NS      m.gtld-servers.net.
;; Received 486 bytes from 198.97.190.53#53(h.root-servers.net) in 116 ms

egal.com.               172800  IN      NS      ns1cny.name.com.
egal.com.               172800  IN      NS      ns2kry.name.com.
egal.com.               172800  IN      NS      ns3dkz.name.com.
egal.com.               172800  IN      NS      ns4bht.name.com.
;; Received 291 bytes from 192.35.51.30#53(f.gtld-servers.net) in 17 ms

egal.com.               300     IN      A       75.126.102.240
;; Received 42 bytes from 162.88.61.49#53(ns3dkz.name.com) in 23 ms

Dig +noall +answer

user@erde$ dig +noall +answer egal.com
egal.com.		267	IN	A	75.126.102.240

Reverse Lookup

user@erde$ dig +noall +answer +short -x 8.8.8.8
dns.google.

getent

user@erde$ getent hosts egal.com
75.126.102.240                          egal.com

Long vs Short

IPv4 Long

user@erde$ dig A dns.google

; <<>> dig 9.10.8-P1 <<>> A dns.google
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57107
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;dns.google.			IN	A

;; ANSWER SECTION:
dns.google.		169	IN	A	8.8.4.4
dns.google.		169	IN	A	8.8.8.8

;; Query time: 0 msec
;; SERVER: 213.133.98.98#53(213.133.98.98)
;; WHEN: Tue May 18 19:25:15 CEST 2021
;; MSG SIZE  rcvd: 71

IPv4 Short

user@erde$ dig A dns.google +short
8.8.8.8
8.8.4.4

IPv6 Long

user@erde$ dig AAAA dns.google

; <<>> dig 9.10.8-P1 <<>> AAAA dns.google
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39920
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;dns.google.			IN	AAAA

;; ANSWER SECTION:
dns.google.		606	IN	AAAA	2001:4860:4860::8888
dns.google.		606	IN	AAAA	2001:4860:4860::8844

;; Query time: 0 msec
;; SERVER: 213.133.98.98#53(213.133.98.98)
;; WHEN: Tue May 18 19:25:23 CEST 2021
;; MSG SIZE  rcvd: 95

IPv6 Short

user@erde$ dig AAAA dns.google +short
2001:4860:4860::8844
2001:4860:4860::8888

Any Comments ?

sha256: 8fab0f8e6ec050002d9ed0890062d2139691794613d0229b9d12bdfa5bc65db0

how to create a bootable usb stick for catalina (MacOS 10.15)

stick: 16 GB

format with GUID, name it USB

cli: sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia –volume /Volumes/USB/ –nointeraction

wait about 20min


Any Comments ?

sha256: 01b5e44e316946854669173480af11682adf6a20f659711acf203473a601d253