Hugo New Page
How to get a new page
This step is how to add a new post within hugo. It will let us actually start adding some content to the site that we are building.
- Open a window command prompt
- In the command prompt type:
cd c:/hugo/sites/example.com
This will change the current directory to c:\hugo\sites\example.com. This is the location that we set up earlier to contain the details of the site that we are creating. - In the command prompt type:
hugo new posts/my-first-post.md
This will actually create the post, and we can then edit and view it. - In the command prompt type:
hugo server -D
This will start the Hugo server, and run our site. The -D flag is used to also display and draft pages that we are currently working on. This command will just continue to run in the background. - Open your browser, and navigate to http://localhost:1313/posts/my-first-post.
You should see an new page has been created - In a text editor (e.g. Notepad++, or Visual Studio Code) open the file at c:/hugo/sites/example.com/posts/my-first-post.md. You can changes in here after the second ‘—’
- Return to your browser, and you should see the changes being reflected once the file has been saved.
- Repeat steps 6 and 7 until you are happy with the content of the page.
For more learning, check out: